"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommandsAction=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var codepipeline=()=>{var tmp=require("../../../aws-codepipeline");return codepipeline=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},action_1=()=>{var tmp=require("../action");return action_1=()=>tmp,tmp};class CommandsAction extends action_1().Action{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_codepipeline_actions.CommandsAction",version:"2.256.1"};outputVariables;constructor(props){super({...props,category:codepipeline().ActionCategory.COMPUTE,provider:"Commands",artifactBounds:{minInputs:1,maxInputs:10,minOutputs:0,maxOutputs:1},inputs:[props.input,...props.extraInputs||[]],outputs:props.output?[props.output]:[],commands:props.commands,outputVariables:props.outputVariables});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_actions_CommandsActionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,CommandsAction),error}if(props.commands.length<1||props.commands.length>50)throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`InvalidCommandsLength`,`The length of the commands array must be between 1 and 50, got: ${props.commands.length}`);if(props.outputVariables!==void 0&&(props.outputVariables.length<1||props.outputVariables.length>15))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`InvalidOutputVariablesLength`,`The length of the outputVariables array must be between 1 and 15, got: ${props.outputVariables.length}`);this.outputVariables=props.outputVariables||[]}variable(variableName){if(!this.outputVariables.includes(variableName))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`VariableNotExported`,`Variable '${variableName}' is not exported by \`outputVariables\`, exported variables: ${this.outputVariables.join(", ")}`);return this.variableExpression(variableName)}bound(scope,stage,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_IStage(stage),jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_ActionBindOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bound),error}const logGroupArn=cdk().Stack.of(scope).formatArn({service:"logs",resource:"log-group",resourceName:`/aws/codepipeline/${stage.pipeline.pipelineName}`,arnFormat:cdk().ArnFormat.COLON_RESOURCE_NAME}),logGroupArnWithWildcard=`${logGroupArn}:*`;return options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({resources:[logGroupArn,logGroupArnWithWildcard],actions:["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"]})),options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({resources:[logGroupArnWithWildcard],actions:["logs:GetLogEvents"]})),(this.actionProperties.inputs??[]).length>0&&options.bucket.grantRead(options.role),(this.actionProperties.outputs??[]).length>0&&options.bucket.grantWrite(options.role),{}}}exports.CommandsAction=CommandsAction;
