"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EcrBuildAndPublishAction=exports.RegistryType=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},ecr=()=>{var tmp=require("../../../aws-ecr");return ecr=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},action_1=()=>{var tmp=require("../action");return action_1=()=>tmp,tmp},RegistryType;(function(RegistryType2){RegistryType2.PRIVATE="private",RegistryType2.PUBLIC="public"})(RegistryType||(exports.RegistryType=RegistryType={}));class EcrBuildAndPublishAction extends action_1().Action{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_codepipeline_actions.EcrBuildAndPublishAction",version:"2.256.1"};props;constructor(props){super({...props,category:codepipeline().ActionCategory.BUILD,provider:"ECRBuildAndPublish",artifactBounds:{minInputs:1,maxInputs:1,minOutputs:0,maxOutputs:0},inputs:[props.input]});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codepipeline_actions_EcrBuildAndPublishActionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EcrBuildAndPublishAction),error}this.props=props}get variables(){return{ecrImageDigestId:this.variableExpression("ECRImageDigestId"),ecrRepositoryName:this.variableExpression("ECRRepositoryName")}}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}if(this.props.registryType===RegistryType.PUBLIC){const repositoryArn=cdk().Stack.of(scope).formatArn({service:"ecr-public",resource:"repository",resourceName:this.props.repositoryName,region:""});options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({resources:[repositoryArn],actions:["ecr-public:DescribeRepositories","ecr-public:InitiateLayerUpload","ecr-public:UploadLayerPart","ecr-public:CompleteLayerUpload","ecr-public:PutImage","ecr-public:BatchCheckLayerAvailability"]})),ecr().PublicGalleryAuthorizationToken.grantRead(options.role)}else{const repositoryArn=cdk().Stack.of(scope).formatArn({service:"ecr",resource:"repository",resourceName:this.props.repositoryName,region:cdk().Stack.of(scope).region});options.role.addToPrincipalPolicy(new(iam()).PolicyStatement({resources:[repositoryArn],actions:["ecr:DescribeRepositories","ecr:InitiateLayerUpload","ecr:UploadLayerPart","ecr:CompleteLayerUpload","ecr:PutImage","ecr:GetDownloadUrlForLayer","ecr:BatchCheckLayerAvailability"]})),ecr().AuthorizationToken.grantRead(options.role)}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"]})),(this.actionProperties.inputs??[]).length>0&&options.bucket.grantRead(options.role),{configuration:{ECRRepositoryName:this.props.repositoryName,DockerFilePath:this.props.dockerfileDirectoryPath,ImageTags:this.props.imageTags!==void 0?this.props.imageTags.join(","):void 0,RegistryType:this.props.registryType}}}}exports.EcrBuildAndPublishAction=EcrBuildAndPublishAction;
