UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 3.6 kB
"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"),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){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_FargateServiceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,FargateService),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.");super(scope,id,{...props,desiredCount:props.desiredCount,launchType:base_service_1.LaunchType.FARGATE,capacityProviderStrategies:props.capacityProviderStrategies,enableECSManagedTags:props.enableECSManagedTags},{cluster:props.cluster.clusterName,taskDefinition:props.deploymentController?.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.referencesSecretJsonField&&props.platformVersion&&SECRET_JSON_FIELD_UNSUPPORTED_PLATFORM_VERSIONS.includes(props.platformVersion)?[`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.`]:[]}),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=from_service_attributes_1.extractServiceNameFromArn(this,fargateServiceArn)}}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.fromServiceAttributes(scope,id,attrs)}}exports.FargateService=FargateService,_a=JSII_RTTI_SYMBOL_1,FargateService[_a]={fqn:"aws-cdk-lib.aws_ecs.FargateService",version:"2.70.0"};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];