Skip to content
v2.273.0

EcrSourceAction Class ​

The ECR Repository source CodePipeline Action.

Will trigger the pipeline as soon as the target tag in the repository changes, but only if there is a CloudTrail Trail in the account that captures the ECR event.

Example ​

ts
import * as ecr from 'aws-cdk-lib/aws-ecr';

declare const ecrRepository: ecr.Repository;
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.EcrSourceAction({
  actionName: 'ECR',
  repository: ecrRepository,
  imageTag: 'some-tag', // optional, default: 'latest'
  output: sourceOutput,
});
pipeline.addStage({
  stageName: 'Source',
  actions: [sourceAction],
});
python
import aws_cdk.aws_ecr as ecr

# ecr_repository: ecr.Repository

pipeline = codepipeline.Pipeline(self, "MyPipeline")
source_output = codepipeline.Artifact()
source_action = codepipeline_actions.EcrSourceAction(
    action_name="ECR",
    repository=ecr_repository,
    image_tag="some-tag",  # optional, default: 'latest'
    output=source_output
)
pipeline.add_stage(
    stage_name="Source",
    actions=[source_action]
)
java
import software.amazon.awscdk.services.ecr.*;

Repository ecrRepository;

Pipeline pipeline = new Pipeline(this, "MyPipeline");
Artifact sourceOutput = new Artifact();
EcrSourceAction sourceAction = EcrSourceAction.Builder.create()
        .actionName("ECR")
        .repository(ecrRepository)
        .imageTag("some-tag") // optional, default: 'latest'
        .output(sourceOutput)
        .build();
pipeline.addStage(StageOptions.builder()
        .stageName("Source")
        .actions(List.of(sourceAction))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.ECR;

Repository ecrRepository;

var pipeline = new Pipeline(this, "MyPipeline");
var sourceOutput = new Artifact();
var sourceAction = new EcrSourceAction(new EcrSourceActionProps {
    ActionName = "ECR",
    Repository = ecrRepository,
    ImageTag = "some-tag",  // optional, default: 'latest'
    Output = sourceOutput
});
pipeline.AddStage(new StageOptions {
    StageName = "Source",
    Actions = new [] { sourceAction }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import ecr "github.com/aws/aws-cdk-go/awscdk"

var ecrRepository Repository

pipeline := codepipeline.NewPipeline(this, jsii.String("MyPipeline"))
sourceOutput := codepipeline.NewArtifact()
sourceAction := codepipeline_actions.NewEcrSourceAction(&EcrSourceActionProps{
	ActionName: jsii.String("ECR"),
	Repository: ecrRepository,
	ImageTag: jsii.String("some-tag"),
	 // optional, default: 'latest'
	Output: sourceOutput,
})
pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Source"),
	Actions: []IAction{
		sourceAction,
	},
})

Initializer ​

ts
new EcrSourceAction(props: EcrSourceActionProps)
python
EcrSourceAction(props: EcrSourceActionProps)
java
new EcrSourceAction(EcrSourceActionProps props)
csharp
new EcrSourceAction(EcrSourceActionProps props)
go
NewEcrSourceAction(Props EcrSourceActionProps)

Properties ​

actionPropertiesActionPropertiesaction_propertiesActionPropertiesactionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesrequired#
The simple properties of the Action, like its Owner, name, etc.

Note that this accessor will be called before the bind callback.

The variables emitted by this action.

Methods ​

bind(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfigdef bind(self, scope: Construct, stage: IStage, options: ActionBindOptions) -> ActionConfigpublic ActionConfig bind(Construct scope, IStage stage, ActionBindOptions options)public ActionConfig Bind(Construct scope, IStage stage, ActionBindOptions options)func Bind(Scope Construct, Stage IStage, Options ActionBindOptions) ActionConfig#
The callback invoked when this Action is added to a Pipeline.
onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Ruledef on_state_change(self, name: str, target: typing.Optional[IRuleTarget] = None, options: typing.Optional[RuleProps] = None) -> Rulepublic Rule onStateChange(String name, IRuleTarget target, RuleProps options)public Rule OnStateChange(string name, IRuleTarget? target = null, RuleProps? options = null)func OnStateChange(Name *string, Target IRuleTarget, Options RuleProps) Rule#
Creates an Event that will be triggered whenever the state of this Action changes.