aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 6.24 kB
JavaScript
var __decorate=exports&&exports.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.FargatePlatformVersion=exports.FargateService=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},availability_zone_rebalancing_1=()=>{var tmp=require("../availability-zone-rebalancing");return availability_zone_rebalancing_1=()=>tmp,tmp},base_service_1=()=>{var tmp=require("../base/base-service");return base_service_1=()=>tmp,tmp},from_service_attributes_1=()=>{var tmp=require("../base/from-service-attributes");return from_service_attributes_1=()=>tmp,tmp};class FargateService extends base_service_1().BaseService{static fromFargateServiceArn(scope,id,fargateServiceArn){class Import extends cdk().Resource{constructor(){super(...arguments),this.serviceArn=fargateServiceArn,this.serviceName=(0,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(0,from_service_attributes_1().fromServiceAttributes)(scope,id,attrs)}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.");if(props.availabilityZoneRebalancing===availability_zone_rebalancing_1().AvailabilityZoneRebalancing.ENABLED&&!cdk().Token.isUnresolved(props.maxHealthyPercent)&&props.maxHealthyPercent===100)throw new Error("AvailabilityZoneRebalancing.ENABLED requires maxHealthyPercent > 100");const unsupportedPlatformVersions=[FargatePlatformVersion.VERSION1_0,FargatePlatformVersion.VERSION1_1,FargatePlatformVersion.VERSION1_2,FargatePlatformVersion.VERSION1_3],isUnsupportedPlatformVersion=props.platformVersion&&unsupportedPlatformVersions.includes(props.platformVersion);if(props.taskDefinition.ephemeralStorageGiB&&isUnsupportedPlatformVersion)throw new Error(`The ephemeralStorageGiB feature requires platform version ${FargatePlatformVersion.VERSION1_4} or later, got ${props.platformVersion}.`);if(props.taskDefinition.pidMode&&isUnsupportedPlatformVersion)throw new Error(`The pidMode feature requires platform version ${FargatePlatformVersion.VERSION1_4} or later, got ${props.platformVersion}.`);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,availabilityZoneRebalancing:props.availabilityZoneRebalancing},props.taskDefinition),(0,metadata_resource_1().addConstructMetadata)(this,props),this.availabilityZoneRebalancingEnabled=props.availabilityZoneRebalancing===availability_zone_rebalancing_1().AvailabilityZoneRebalancing.ENABLED;let securityGroups;props.securityGroup!==void 0?securityGroups=[props.securityGroup]:props.securityGroups!==void 0&&(securityGroups=props.securityGroups),(!props.deploymentController||props.deploymentController.type!==base_service_1().DeploymentControllerType.EXTERNAL)&&this.configureAwsVpcNetworkingWithSecurityGroups(props.cluster.vpc,props.assignPublicIp,props.vpcSubnets,securityGroups),this.node.addValidation({validate:()=>this.taskDefinition.referencesSecretJsonField&&isUnsupportedPlatformVersion?[`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"]})}attachToClassicLB(loadBalancer){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancing_LoadBalancer(loadBalancer)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.attachToClassicLB),error}if(this.availabilityZoneRebalancingEnabled)throw new Error("AvailabilityZoneRebalancing.ENABLED disallows using the service as a target of a Classic Load Balancer");super.attachToClassicLB(loadBalancer)}}exports.FargateService=FargateService,_a=JSII_RTTI_SYMBOL_1,FargateService[_a]={fqn:"aws-cdk-lib.aws_ecs.FargateService",version:"2.185.0"},__decorate([(0,metadata_resource_1().MethodMetadata)()],FargateService.prototype,"attachToClassicLB",null);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=FargatePlatformVersion={}));
;