"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EcrSourceAction=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},aws_events_1=()=>{var tmp=require("../../../aws-events");return aws_events_1=()=>tmp,tmp},targets=()=>{var tmp=require("../../../aws-events-targets");return targets=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},action_1=()=>{var tmp=require("../action");return action_1=()=>tmp,tmp},common_1=()=>{var tmp=require("../common");return common_1=()=>tmp,tmp};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.159.0"};
