"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EcrSourceAction=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),codepipeline=require("../../../aws-codepipeline"),aws_events_1=require("../../../aws-events"),targets=require("../../../aws-events-targets"),iam=require("../../../aws-iam"),core_1=require("../../../core"),action_1=require("../action"),common_1=require("../common");class EcrSourceAction extends action_1.Action{constructor(props){super({...props,resource:props.repository,category:codepipeline.ActionCategory.SOURCE,provider:"ECR",artifactBounds:(0,common_1.sourceArtifactBounds)(),outputs:[props.output]});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_codepipeline_actions_EcrSourceActionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EcrSourceAction),error}this.props=props}get variables(){return{registryId:this.variableExpression("RegistryId"),repositoryName:this.variableExpression("RepositoryName"),imageDigest:this.variableExpression("ImageDigest"),imageTag:this.variableExpression("ImageTag"),imageUri:this.variableExpression("ImageURI")}}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}return options.role.addToPolicy(new iam.PolicyStatement({actions:["ecr:DescribeImages"],resources:[this.props.repository.repositoryArn]})),new aws_events_1.Rule(scope,core_1.Names.nodeUniqueId(stage.pipeline.node)+"SourceEventRule",{targets:[new targets.CodePipeline(stage.pipeline)],eventPattern:{detailType:["ECR Image Action"],source:["aws.ecr"],detail:{result:["SUCCESS"],"repository-name":[this.props.repository.repositoryName],"image-tag":[this.props.imageTag===""?void 0:this.props.imageTag??"latest"],"action-type":["PUSH"]}}}),options.bucket.grantWrite(options.role),{configuration:{RepositoryName:this.props.repository.repositoryName,ImageTag:this.props.imageTag?this.props.imageTag:void 0}}}}exports.EcrSourceAction=EcrSourceAction,_a=JSII_RTTI_SYMBOL_1,EcrSourceAction[_a]={fqn:"aws-cdk-lib.aws_codepipeline_actions.EcrSourceAction",version:"2.96.1"};
