"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApplicationLoadBalancedEc2Service=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),aws_ecs_1=require("../../../aws-ecs"),core_1=require("../../../core"),cxapi=require("../../../cx-api"),application_load_balanced_service_base_1=require("../base/application-load-balanced-service-base");class ApplicationLoadBalancedEc2Service extends application_load_balanced_service_base_1.ApplicationLoadBalancedServiceBase{constructor(scope,id,props={}){super(scope,id,props);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_patterns_ApplicationLoadBalancedEc2ServiceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ApplicationLoadBalancedEc2Service),error}if(props.taskDefinition&&props.taskImageOptions)throw new Error("You must specify either a taskDefinition or taskImageOptions, not both.");if(props.taskDefinition)this.taskDefinition=props.taskDefinition;else if(props.taskImageOptions){const taskImageOptions=props.taskImageOptions;this.taskDefinition=new aws_ecs_1.Ec2TaskDefinition(this,"TaskDef",{executionRole:taskImageOptions.executionRole,taskRole:taskImageOptions.taskRole,family:taskImageOptions.family});const enableLogging=taskImageOptions.enableLogging??!0,logDriver=taskImageOptions.logDriver??(enableLogging?this.createAWSLogDriver(this.node.id):void 0),containerName=taskImageOptions.containerName??"web";this.taskDefinition.addContainer(containerName,{image:taskImageOptions.image,cpu:props.cpu,memoryLimitMiB:props.memoryLimitMiB,memoryReservationMiB:props.memoryReservationMiB,environment:taskImageOptions.environment,secrets:taskImageOptions.secrets,logging:logDriver,dockerLabels:taskImageOptions.dockerLabels,command:taskImageOptions.command,entryPoint:taskImageOptions.entryPoint}).addPortMappings({containerPort:taskImageOptions.containerPort||80})}else throw new Error("You must specify one of: taskDefinition or image");const desiredCount=core_1.FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT)?this.internalDesiredCount:this.desiredCount;this.service=new aws_ecs_1.Ec2Service(this,"Service",{cluster:this.cluster,desiredCount,taskDefinition:this.taskDefinition,assignPublicIp:!1,serviceName:props.serviceName,healthCheckGracePeriod:props.healthCheckGracePeriod,minHealthyPercent:props.minHealthyPercent,maxHealthyPercent:props.maxHealthyPercent,propagateTags:props.propagateTags,enableECSManagedTags:props.enableECSManagedTags,cloudMapOptions:props.cloudMapOptions,deploymentController:props.deploymentController,circuitBreaker:props.circuitBreaker,enableExecuteCommand:props.enableExecuteCommand,placementConstraints:props.placementConstraints,placementStrategies:props.placementStrategies,capacityProviderStrategies:props.capacityProviderStrategies}),this.addServiceAsTarget(this.service)}}exports.ApplicationLoadBalancedEc2Service=ApplicationLoadBalancedEc2Service,_a=JSII_RTTI_SYMBOL_1,ApplicationLoadBalancedEc2Service[_a]={fqn:"aws-cdk-lib.aws_ecs_patterns.ApplicationLoadBalancedEc2Service",version:"2.96.1"};
