"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.NetworkLoadBalancedFargateService=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"),network_load_balanced_service_base_1=require("../base/network-load-balanced-service-base");class NetworkLoadBalancedFargateService extends network_load_balanced_service_base_1.NetworkLoadBalancedServiceBase{constructor(scope,id,props={}){super(scope,id,props);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_patterns_NetworkLoadBalancedFargateServiceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,NetworkLoadBalancedFargateService),error}if(this.assignPublicIp=props.assignPublicIp??!1,props.taskDefinition&&props.taskImageOptions)throw new Error("You must specify either a taskDefinition or an image, not both.");if(props.taskDefinition)this.taskDefinition=props.taskDefinition;else if(props.taskImageOptions){const taskImageOptions=props.taskImageOptions;this.taskDefinition=new aws_ecs_1.FargateTaskDefinition(this,"TaskDef",{memoryLimitMiB:props.memoryLimitMiB,cpu:props.cpu,executionRole:taskImageOptions.executionRole,taskRole:taskImageOptions.taskRole,family:taskImageOptions.family,runtimePlatform:props.runtimePlatform});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,logging:logDriver,environment:taskImageOptions.environment,secrets:taskImageOptions.secrets,dockerLabels:taskImageOptions.dockerLabels}).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.FargateService(this,"Service",{cluster:this.cluster,desiredCount,taskDefinition:this.taskDefinition,assignPublicIp:this.assignPublicIp,serviceName:props.serviceName,healthCheckGracePeriod:props.healthCheckGracePeriod,minHealthyPercent:props.minHealthyPercent,maxHealthyPercent:props.maxHealthyPercent,propagateTags:props.propagateTags,enableECSManagedTags:props.enableECSManagedTags,cloudMapOptions:props.cloudMapOptions,platformVersion:props.platformVersion,deploymentController:props.deploymentController,circuitBreaker:props.circuitBreaker,vpcSubnets:props.taskSubnets,enableExecuteCommand:props.enableExecuteCommand,capacityProviderStrategies:props.capacityProviderStrategies}),this.addServiceAsTarget(this.service)}}exports.NetworkLoadBalancedFargateService=NetworkLoadBalancedFargateService,_a=JSII_RTTI_SYMBOL_1,NetworkLoadBalancedFargateService[_a]={fqn:"aws-cdk-lib.aws_ecs_patterns.NetworkLoadBalancedFargateService",version:"2.96.1"};
