"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.FargatePlatformVersion=exports.FargateService=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cdk=require("../../../core"),core_1=require("../../../core"),base_service_1=require("../base/base-service"),from_service_attributes_1=require("../base/from-service-attributes");class FargateService extends base_service_1.BaseService{constructor(scope,id,props){var _b;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_FargateServiceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.constructor),error}if(!props.taskDefinition.isFargateCompatible)throw new Error("Supplied TaskDefinition is not configured for compatibility with Fargate");if(props.securityGroup!==void 0&&props.securityGroups!==void 0)throw new Error("Only one of SecurityGroup or SecurityGroups can be populated.");if(props.taskDefinition.referencesSecretJsonField&&props.platformVersion&&SECRET_JSON_FIELD_UNSUPPORTED_PLATFORM_VERSIONS.includes(props.platformVersion))throw new Error(`The task definition of this service uses at least one container that references a secret JSON field. This feature requires platform version ${FargatePlatformVersion.VERSION1_4} or later.`);super(scope,id,{...props,desiredCount:props.desiredCount,launchType:base_service_1.LaunchType.FARGATE,capacityProviderStrategies:props.capacityProviderStrategies,enableECSManagedTags:props.enableECSManagedTags},{cluster:props.cluster.clusterName,taskDefinition:((_b=props.deploymentController)===null||_b===void 0?void 0:_b.type)===base_service_1.DeploymentControllerType.EXTERNAL?void 0:props.taskDefinition.taskDefinitionArn,platformVersion:props.platformVersion},props.taskDefinition);let securityGroups;props.securityGroup!==void 0?securityGroups=[props.securityGroup]:props.securityGroups!==void 0&&(securityGroups=props.securityGroups),this.configureAwsVpcNetworkingWithSecurityGroups(props.cluster.vpc,props.assignPublicIp,props.vpcSubnets,securityGroups),this.node.addValidation({validate:()=>this.taskDefinition.defaultContainer?[]:["A TaskDefinition must have at least one essential container"]})}static fromFargateServiceArn(scope,id,fargateServiceArn){class Import extends cdk.Resource{constructor(){super(...arguments),this.serviceArn=fargateServiceArn,this.serviceName=cdk.Stack.of(scope).splitArn(fargateServiceArn,core_1.ArnFormat.SLASH_RESOURCE_NAME).resourceName}}return new Import(scope,id)}static fromFargateServiceAttributes(scope,id,attrs){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_FargateServiceAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromFargateServiceAttributes),error}return from_service_attributes_1.fromServiceAtrributes(scope,id,attrs)}}exports.FargateService=FargateService,_a=JSII_RTTI_SYMBOL_1,FargateService[_a]={fqn:"aws-cdk-lib.aws_ecs.FargateService",version:"2.24.1"};var FargatePlatformVersion;(function(FargatePlatformVersion2){FargatePlatformVersion2.LATEST="LATEST",FargatePlatformVersion2.VERSION1_4="1.4.0",FargatePlatformVersion2.VERSION1_3="1.3.0",FargatePlatformVersion2.VERSION1_2="1.2.0",FargatePlatformVersion2.VERSION1_1="1.1.0",FargatePlatformVersion2.VERSION1_0="1.0.0"})(FargatePlatformVersion=exports.FargatePlatformVersion||(exports.FargatePlatformVersion={}));const SECRET_JSON_FIELD_UNSUPPORTED_PLATFORM_VERSIONS=[FargatePlatformVersion.VERSION1_0,FargatePlatformVersion.VERSION1_1,FargatePlatformVersion.VERSION1_2,FargatePlatformVersion.VERSION1_3];
//# sourceMappingURL=fargate-service.js.map
