"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExternalService=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../../core"),base_service_1=require("../base/base-service"),from_service_attributes_1=require("../base/from-service-attributes"),task_definition_1=require("../base/task-definition");class ExternalService extends base_service_1.BaseService{constructor(scope,id,props){var _b,_c;if(jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_ExternalServiceProps(props),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.enableExecuteCommand!==void 0)throw new Error("Enable Execute Command 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=(_b=props.propagateTags)!==null&&_b!==void 0?_b: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:((_c=props.deploymentController)===null||_c===void 0?void 0:_c.type)===base_service_1.DeploymentControllerType.EXTERNAL?void 0:props.taskDefinition.taskDefinitionArn},props.taskDefinition);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"]:[]})}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){return jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_ExternalServiceAttributes(attrs),from_service_attributes_1.fromServiceAtrributes(scope,id,attrs)}attachToApplicationTargetGroup(_targetGroup){throw jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_IApplicationTargetGroup(_targetGroup),new Error("Application load balancer cannot be attached to an external service")}loadBalancerTarget(_options){throw jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_LoadBalancerTargetOptions(_options),new Error("External service cannot be attached as load balancer targets")}registerLoadBalancerTargets(..._targets){throw jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_EcsTarget(_targets),new Error("External service cannot be registered as load balancer targets")}configureAwsVpcNetworkingWithSecurityGroups(_vpc,_assignPublicIp,_vpcSubnets,_securityGroups){throw jsiiDeprecationWarnings.aws_cdk_lib_aws_ec2_IVpc(_vpc),jsiiDeprecationWarnings.aws_cdk_lib_aws_ec2_SubnetSelection(_vpcSubnets),new Error("Only Bridge network mode is supported for external service")}autoScaleTaskCount(_props){throw jsiiDeprecationWarnings.aws_cdk_lib_aws_applicationautoscaling_EnableScalingProps(_props),new Error("Autoscaling not supported for external service")}enableCloudMap(_options){throw jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_CloudMapOptions(_options),new Error("Cloud map integration not supported for an external service")}associateCloudMapService(_options){throw jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_AssociateCloudMapServiceOptions(_options),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.13.0"};
//# sourceMappingURL=external-service.js.map
