# EcrSourceAction

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.

Extends: Action › Action › EcrSourceAction
Implements: IAction

- Source: [`aws-codepipeline-actions/lib/ecr/source-action.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-codepipeline-actions/lib/ecr/source-action.ts#L62)
- Type last changed: v2.38.0 · 17 Aug 2022

## 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],
});
```

## Initializer

```ts
new EcrSourceAction(props: EcrSourceActionProps)
```

## Properties

- `actionProperties`: [ActionProperties](/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.ActionProperties.html) — The simple properties of the Action, like its Owner, name, etc.

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

- `variables`: [EcrSourceVariables](/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline_actions.EcrSourceVariables.html) — The variables emitted by this action.

## Methods

- `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): Rule` — Creates an Event that will be triggered whenever the state of this Action changes.
