"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.AwsLogDriver=exports.AwsLogDriverMode=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var log_driver_1=()=>{var tmp=require("./log-driver");return log_driver_1=()=>tmp,tmp},utils_1=()=>{var tmp=require("./utils");return utils_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},logs=()=>{var tmp=require("../../../aws-logs");return logs=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},AwsLogDriverMode;(function(AwsLogDriverMode2){AwsLogDriverMode2.BLOCKING="blocking",AwsLogDriverMode2.NON_BLOCKING="non-blocking"})(AwsLogDriverMode||(exports.AwsLogDriverMode=AwsLogDriverMode={}));class AwsLogDriver extends log_driver_1().LogDriver{constructor(props){super(),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_AwsLogDriverProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,AwsLogDriver),error}if(props.logGroup&&props.logRetention)throw new Error("Cannot specify both `logGroup` and `logRetentionDays`.");if(props.maxBufferSize&&props.mode!==AwsLogDriverMode.NON_BLOCKING)throw new Error("Cannot specify `maxBufferSize` when the driver mode is blocking")}bind(scope,containerDefinition){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecs_ContainerDefinition(containerDefinition)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}this.logGroup=this.props.logGroup||new(logs()).LogGroup(scope,"LogGroup",{retention:this.props.logRetention||1/0});const maxBufferSize=this.props.maxBufferSize?`${this.props.maxBufferSize.toBytes({rounding:core_1().SizeRoundingBehavior.FLOOR})}b`:void 0;return containerDefinition.taskDefinition.obtainExecutionRole().addToPrincipalPolicy(new(iam()).PolicyStatement({actions:["logs:CreateLogStream","logs:PutLogEvents"],resources:[this.logGroup.logGroupArn]})),{logDriver:"awslogs",options:(0,utils_1().removeEmpty)({"awslogs-group":this.logGroup.logGroupName,"awslogs-stream-prefix":this.props.streamPrefix,"awslogs-region":this.logGroup.env.region,"awslogs-datetime-format":this.props.datetimeFormat,"awslogs-multiline-pattern":this.props.multilinePattern,mode:this.props.mode,"max-buffer-size":maxBufferSize})}}}exports.AwsLogDriver=AwsLogDriver,_a=JSII_RTTI_SYMBOL_1,AwsLogDriver[_a]={fqn:"aws-cdk-lib.aws_ecs.AwsLogDriver",version:"2.148.1"};
