UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 8.46 kB
"use strict";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.ExternalService=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../../core/lib/metadata-resource");return metadata_resource_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},task_definition_1=()=>{var tmp=require("../base/task-definition");return task_definition_1=()=>tmp,tmp};class ExternalService extends base_service_1().BaseService{static fromExternalServiceArn(scope,id,externalServiceArn){class Import extends core_1().Resource{constructor(){super(...arguments),this.serviceArn=externalServiceArn,this.serviceName=core_1().Stack.of(scope).splitArn(externalServiceArn,core_1().ArnFormat.SLASH_RESOURCE_NAME).resourceName}}return new Import(scope,id)}static fromExternalServiceAttributes(scope,id,attrs){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_ExternalServiceAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromExternalServiceAttributes),error}return(0,from_service_attributes_1().fromServiceAttributes)(scope,id,attrs)}constructor(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_ExternalServiceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ExternalService),error}if(props.daemon){if(props.deploymentController?.type===base_service_1().DeploymentControllerType.EXTERNAL||props.deploymentController?.type===base_service_1().DeploymentControllerType.CODE_DEPLOY)throw new Error("CODE_DEPLOY or EXTERNAL deployment controller types don't support the DAEMON scheduling strategy.");if(props.desiredCount!==void 0)throw new Error("Daemon mode launches one task on every instance. Cannot specify desiredCount when daemon mode is enabled.");if(props.maxHealthyPercent!==void 0&&props.maxHealthyPercent!==100)throw new Error("Maximum percent must be 100 when daemon mode is enabled.")}if(props.minHealthyPercent!==void 0&&props.maxHealthyPercent!==void 0&&props.minHealthyPercent>=props.maxHealthyPercent)throw new Error("Minimum healthy percent must be less than maximum healthy percent.");if(props.taskDefinition.compatibility!==task_definition_1().Compatibility.EXTERNAL)throw new Error("Supplied TaskDefinition is not configured for compatibility with ECS Anywhere cluster");if(props.cluster.defaultCloudMapNamespace!==void 0)throw new Error(`Cloud map integration is not supported for External service ${props.cluster.defaultCloudMapNamespace}`);if(props.cloudMapOptions!==void 0)throw new Error("Cloud map options are not supported for External service");if(props.capacityProviderStrategies!==void 0)throw new Error("Capacity Providers are not supported for External service");const propagateTagsFromSource=props.propagateTags??base_service_1().PropagatedTagSource.NONE;super(scope,id,{...props,desiredCount:props.desiredCount,maxHealthyPercent:props.maxHealthyPercent===void 0?100:props.maxHealthyPercent,minHealthyPercent:props.minHealthyPercent===void 0?0:props.minHealthyPercent,launchType:base_service_1().LaunchType.EXTERNAL,propagateTags:propagateTagsFromSource,enableECSManagedTags:props.enableECSManagedTags},{cluster:props.cluster.clusterName,taskDefinition:props.deploymentController?.type===base_service_1().DeploymentControllerType.EXTERNAL?void 0:props.taskDefinition.taskDefinitionArn,schedulingStrategy:props.daemon?"DAEMON":void 0},props.taskDefinition),(0,metadata_resource_1().addConstructMetadata)(this,props),this.node.addValidation({validate:()=>this.taskDefinition.defaultContainer?[]:["A TaskDefinition must have at least one essential container"]}),this.node.addValidation({validate:()=>this.networkConfiguration!==void 0?["Network configurations not supported for an external service"]:[]}),props.minHealthyPercent===void 0&&core_1().Annotations.of(this).addWarningV2("@aws-cdk/aws-ecs:minHealthyPercentExternal","minHealthyPercent has not been configured so the default value of 0% for an external service is used. The number of running tasks will decrease below the desired count during deployments etc. See https://github.com/aws/aws-cdk/issues/31705")}attachToApplicationTargetGroup(_targetGroup){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_IApplicationTargetGroup(_targetGroup)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.attachToApplicationTargetGroup),error}throw new Error("Application load balancer cannot be attached to an external service")}loadBalancerTarget(_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_LoadBalancerTargetOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.loadBalancerTarget),error}throw new Error("External service cannot be attached as load balancer targets")}registerLoadBalancerTargets(..._targets){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_EcsTarget(_targets)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.registerLoadBalancerTargets),error}throw new Error("External service cannot be registered as load balancer targets")}configureAwsVpcNetworkingWithSecurityGroups(_vpc,_assignPublicIp,_vpcSubnets,_securityGroups){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IVpc(_vpc),jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_SubnetSelection(_vpcSubnets)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.configureAwsVpcNetworkingWithSecurityGroups),error}throw new Error("Only Bridge network mode is supported for external service")}autoScaleTaskCount(_props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_applicationautoscaling_EnableScalingProps(_props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.autoScaleTaskCount),error}throw new Error("Autoscaling not supported for external service")}enableCloudMap(_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_CloudMapOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.enableCloudMap),error}throw new Error("Cloud map integration not supported for an external service")}associateCloudMapService(_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_AssociateCloudMapServiceOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.associateCloudMapService),error}throw new Error("Cloud map service association is not supported for an external service")}}exports.ExternalService=ExternalService,_a=JSII_RTTI_SYMBOL_1,ExternalService[_a]={fqn:"aws-cdk-lib.aws_ecs.ExternalService",version:"2.185.0"},__decorate([(0,metadata_resource_1().MethodMetadata)()],ExternalService.prototype,"attachToApplicationTargetGroup",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],ExternalService.prototype,"loadBalancerTarget",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],ExternalService.prototype,"registerLoadBalancerTargets",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],ExternalService.prototype,"autoScaleTaskCount",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],ExternalService.prototype,"enableCloudMap",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],ExternalService.prototype,"associateCloudMapService",null);