"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EcsJobDefinition=exports.Compatibility=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var batch_generated_1=()=>{var tmp=require("./batch.generated");return batch_generated_1=()=>tmp,tmp},ecs_container_definition_1=()=>{var tmp=require("./ecs-container-definition");return ecs_container_definition_1=()=>tmp,tmp},job_definition_base_1=()=>{var tmp=require("./job-definition-base");return job_definition_base_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},Compatibility;(function(Compatibility2){Compatibility2.EC2="EC2",Compatibility2.FARGATE="FARGATE"})(Compatibility||(exports.Compatibility=Compatibility={}));class EcsJobDefinition extends job_definition_base_1().JobDefinitionBase{static fromJobDefinitionArn(scope,id,jobDefinitionArn){class Import extends job_definition_base_1().JobDefinitionBase{constructor(){super(...arguments),this.jobDefinitionArn=jobDefinitionArn,this.jobDefinitionName=EcsJobDefinition.getJobDefinitionName(this,jobDefinitionArn),this.enabled=!0,this.container={}}}return new Import(scope,id)}static getJobDefinitionName(scope,jobDefinitionArn){return core_1().Stack.of(scope).splitArn(jobDefinitionArn,core_1().ArnFormat.SLASH_RESOURCE_NAME).resourceName.split(":")[0]}constructor(scope,id,props){super(scope,id,props);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_batch_EcsJobDefinitionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EcsJobDefinition),error}this.container=props.container,this.propagateTags=props?.propagateTags;const resource=new(batch_generated_1()).CfnJobDefinition(this,"Resource",{...(0,job_definition_base_1().baseJobDefinitionProperties)(this),type:"container",jobDefinitionName:props.jobDefinitionName,containerProperties:this.container?._renderContainerDefinition(),platformCapabilities:this.renderPlatformCapabilities(),propagateTags:this.propagateTags});this.jobDefinitionArn=this.getResourceArnAttribute(resource.ref,{service:"batch",resource:"job-definition",resourceName:this.physicalName}),this.jobDefinitionName=EcsJobDefinition.getJobDefinitionName(scope,this.jobDefinitionArn)}grantSubmitJob(identity,queue){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(identity),jsiiDeprecationWarnings().aws_cdk_lib_aws_batch_IJobQueue(queue)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.grantSubmitJob),error}iam().Grant.addToPrincipal({actions:["batch:SubmitJob"],grantee:identity,resourceArns:[this.jobDefinitionArn,queue.jobQueueArn]})}renderPlatformCapabilities(){return this.container instanceof ecs_container_definition_1().EcsEc2ContainerDefinition?[Compatibility.EC2]:[Compatibility.FARGATE]}}exports.EcsJobDefinition=EcsJobDefinition,_a=JSII_RTTI_SYMBOL_1,EcsJobDefinition[_a]={fqn:"aws-cdk-lib.aws_batch.EcsJobDefinition",version:"2.159.0"};
