This documentation is for the developer preview release of the AWS CDK. Do not use this version of the AWS CDK in production. Subsequent releases of the AWS CDK will likely include breaking changes.

@aws-cdk/aws-ecr

Amazon Elastic Container Registry Construct Library

This package contains constructs for working with Amazon Elastic Container Registry.

Repositories

Define a repository by creating a new instance of Repository. A repository holds multiple verions of a single container image.

const repository = new ecr.Repository(this, 'Repository');

Automatically clean up repositories

You can set life cycle rules to automatically clean up old images from your repository. The first life cycle rule that matches an image will be applied against that image. For example, the following deletes images older than 30 days, while keeping all images tagged with prod (note that the order is important here):

repository.addLifecycleRule({ tagPrefixList: ['prod'], maxImageCount: 9999 });
repository.addLifecycleRule({ maxImageAgeDays: 30 });

Using with CodePipeline

This package also contains a source Action that allows you to use an ECR Repository as a source for CodePipeline. Example:

import codepipeline = require('@aws-cdk/aws-codepipeline');

const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const sourceAction = new ecr.PipelineSourceAction({
  actionName: 'ECR',
  repository: ecrRepository,
  imageTag: 'some-tag', // optional, default: 'latest'
  outputArtifactName: 'SomeName', // optional
});
pipeline.addStage({
  actionName: 'Source',
  actions: [sourceAction],
});

You can also create the action from the Repository directly:

// equivalent to the code above:
const sourceAction = ecrRepository.toCodePipelineSourceAction({ actionName: 'ECR' });

Reference

View in Nuget

csproj:

<PackageReference Include="Amazon.CDK.AWS.ECR" Version="0.25.3" />

dotnet:

dotnet add package Amazon.CDK.AWS.ECR --version 0.25.3

packages.config:

<package id="Amazon.CDK.AWS.ECR" version="0.25.3" />

View in Maven Central

Apache Buildr:

'software.amazon.awscdk:ecr:jar:0.25.3'

Apache Ivy:

<dependency groupId="software.amazon.awscdk" name="ecr" rev="0.25.3"/>

Apache Maven:

<dependency>
  <groupId>software.amazon.awscdk</groupId>
  <artifactId>ecr</artifactId>
  <version>0.25.3</version>
</dependency>

Gradle / Grails:

compile 'software.amazon.awscdk:ecr:0.25.3'

Groovy Grape:

@Grapes(
@Grab(group='software.amazon.awscdk', module='ecr', version='0.25.3')
)

View in NPM

npm:

$ npm i @aws-cdk/aws-ecr@0.25.3

package.json:

{
  "@aws-cdk/aws-ecr": "^0.25.3"
}

yarn:

$ yarn add @aws-cdk/aws-ecr@0.25.3

View in NPM

npm:

$ npm i @aws-cdk/aws-ecr@0.25.3

package.json:

{
  "@aws-cdk/aws-ecr": "^0.25.3"
}

yarn:

$ yarn add @aws-cdk/aws-ecr@0.25.3

CfnRepository

class @aws-cdk/aws-ecr.CfnRepository(scope, id[, props])

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.CfnRepository;
const { CfnRepository } = require('@aws-cdk/aws-ecr');
import { CfnRepository } from '@aws-cdk/aws-ecr';
Extends:

@aws-cdk/cdk.Resource

Parameters:
renderProperties(properties) → string => any

Overrides @aws-cdk/cdk.Resource.renderProperties()

Protected method

Parameters:properties (any) –
Return type:string => any
resourceTypeName

The CloudFormation resource type name for this resource class.

Type:string (readonly) (static)
propertyOverrides
Type:CfnRepositoryProps (readonly)
repositoryArn
Type:string (readonly)
repositoryName
Type:string (readonly)
class LifecyclePolicyProperty

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.CfnRepository.LifecyclePolicyProperty;
// CfnRepository.LifecyclePolicyProperty is an interface
import { CfnRepository.LifecyclePolicyProperty } from '@aws-cdk/aws-ecr';
lifecyclePolicyText

CfnRepository.LifecyclePolicyProperty.LifecyclePolicyText

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-repository-lifecyclepolicy.html#cfn-ecr-repository-lifecyclepolicy-lifecyclepolicytext

Type:string (optional)
registryId

CfnRepository.LifecyclePolicyProperty.RegistryId

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-repository-lifecyclepolicy.html#cfn-ecr-repository-lifecyclepolicy-registryid

Type:string (optional)
toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)
ref

Inherited from @aws-cdk/cdk.Referenceable

Returns a token to a CloudFormation { Ref } that references this entity based on it’s logical ID.

Type:string (readonly)
addDeletionOverride(path)

Inherited from @aws-cdk/cdk.Resource

Syntactic sugar for addOverride(path, undefined).

Parameters:path (string) – The path of the value to delete
addDependsOn(resource)

Inherited from @aws-cdk/cdk.Resource

Indicates that this resource depends on another resource and cannot be provisioned

unless the other resource has been successfully provisioned.

Parameters:resource (@aws-cdk/cdk.Resource) –
addOverride(path, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to the synthesized CloudFormation resource. To add a

property override, either use addPropertyOverride or prefix path with

“Properties.” (i.e. Properties.TopicName).

Parameters:
  • path (string) – The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
  • value (any) – The value. Could be primitive or complex.
addPropertyDeletionOverride(propertyPath)

Inherited from @aws-cdk/cdk.Resource

Adds an override that deletes the value of a property from the resource definition.

Parameters:propertyPath (string) – The path to the property.
addPropertyOverride(propertyPath, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to a resource property.

Syntactic sugar for addOverride(“Properties.<…>”, value).

Parameters:
  • propertyPath (string) – The path of the property
  • value (any) – The value
getAtt(attributeName) → @aws-cdk/cdk.CfnReference

Inherited from @aws-cdk/cdk.Resource

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility

in case there is no generated attribute.

Parameters:attributeName (string) – The name of the attribute.
Return type:@aws-cdk/cdk.CfnReference
toCloudFormation() → json

Inherited from @aws-cdk/cdk.Resource

Emits CloudFormation for this resource.

Return type:json
options

Inherited from @aws-cdk/cdk.Resource

Options for this resource, such as condition, update policy etc.

Type:@aws-cdk/cdk.ResourceOptions (readonly)
properties

Inherited from @aws-cdk/cdk.Resource

AWS resource properties.

This object is rendered via a call to “renderProperties(this.properties)”.

Protected property

Type:any (readonly)
resourceType

Inherited from @aws-cdk/cdk.Resource

AWS resource type.

Type:string (readonly)
untypedPropertyOverrides

Inherited from @aws-cdk/cdk.Resource

AWS resource property overrides.

During synthesis, the method “renderProperties(this.overrides)” is called

with this object, and merged on top of the output of

“renderProperties(this.properties)”.

Derived classes should expose a strongly-typed version of this object as

a public property called propertyOverrides.

Protected property

Type:any (readonly)
overrideLogicalId(newLogicalId)

Inherited from @aws-cdk/cdk.StackElement

Overrides the auto-generated logical ID with a specific ID.

Parameters:newLogicalId (string) – The new logical ID to use for this stack element.
prepare()

Inherited from @aws-cdk/cdk.StackElement

Automatically detect references in this StackElement

Protected method

creationStackTrace

Inherited from @aws-cdk/cdk.StackElement

Type:string[] (readonly)
logicalId

Inherited from @aws-cdk/cdk.StackElement

The logical ID for this CloudFormation stack element. The logical ID of the element

is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

Type:string (readonly)
stackPath

Inherited from @aws-cdk/cdk.StackElement

Return the path with respect to the stack

Type:string (readonly)

CfnRepositoryProps (interface)

class @aws-cdk/aws-ecr.CfnRepositoryProps

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.CfnRepositoryProps;
// CfnRepositoryProps is an interface
import { CfnRepositoryProps } from '@aws-cdk/aws-ecr';
lifecyclePolicy

AWS::ECR::Repository.LifecyclePolicy

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-lifecyclepolicy

Type:LifecyclePolicyProperty or @aws-cdk/cdk.Token (optional)
repositoryName

AWS::ECR::Repository.RepositoryName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-repositoryname

Type:string (optional)
repositoryPolicyText

AWS::ECR::Repository.RepositoryPolicyText

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-repositorypolicytext

Type:json or @aws-cdk/cdk.Token (optional)

CommonPipelineSourceActionProps (interface)

class @aws-cdk/aws-ecr.CommonPipelineSourceActionProps

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.CommonPipelineSourceActionProps;
// CommonPipelineSourceActionProps is an interface
import { CommonPipelineSourceActionProps } from '@aws-cdk/aws-ecr';

Common properties for the {@link PipelineSourceAction CodePipeline source Action},

whether creating it directly,

or through the {@link IRepository#toCodePipelineSourceAction} method.

Extends:@aws-cdk/aws-codepipeline-api.CommonActionProps
imageTag

The image tag that will be checked for changes.

Type:string (optional)
Default:‘latest’
outputArtifactName

The name of the source’s output artifact.

Output artifacts are used by CodePipeline as inputs into other actions.

Type:string (optional)
Default:a name will be auto-generated
actionName

Inherited from @aws-cdk/aws-codepipeline-api.CommonActionProps

The physical, human-readable name of the Action.

Not that Action names must be unique within a single Stage.

Type:string
runOrder

Inherited from @aws-cdk/aws-codepipeline-api.CommonActionProps

The runOrder property for this Action.

RunOrder determines the relative order in which multiple Actions in the same Stage execute.

Type:number (optional)
Default:1

CountType (enum)

class @aws-cdk/aws-ecr.CountType

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.CountType;
const { CountType } = require('@aws-cdk/aws-ecr');
import { CountType } from '@aws-cdk/aws-ecr';

Select images based on counts

ImageCountMoreThan

Set a limit on the number of images in your repository

SinceImagePushed

Set an age limit on the images in your repository

IRepository (interface)

class @aws-cdk/aws-ecr.IRepository

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.IRepository;
// IRepository is an interface
import { IRepository } from '@aws-cdk/aws-ecr';

Represents an ECR repository.

Extends:@aws-cdk/cdk.IConstruct
repositoryArn

The ARN of the repository

Type:string (readonly)
repositoryName

The name of the repository

Type:string (readonly)
repositoryUri

The URI of this repository (represents the latest image):

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY
Type:string (readonly)
addToResourcePolicy(statement)

Add a policy statement to the repository’s resource policy

Parameters:statement (@aws-cdk/aws-iam.PolicyStatement) –
Abstract:Yes
export() → @aws-cdk/aws-ecr.RepositoryImportProps

Export this repository from the stack

Return type:RepositoryImportProps
Abstract:Yes
grant(identity, *actions)

Grant the given principal identity permissions to perform the actions on this repository

Parameters:
Abstract:

Yes

grantPull([identity])

Grant the given identity permissions to pull images in this repository.

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
Abstract:Yes
grantPullPush([identity])

Grant the given identity permissions to pull and push images to this repository.

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
Abstract:Yes
onImagePushed(name[, target[, imageTag]]) → @aws-cdk/aws-events.EventRule

Defines an AWS CloudWatch event rule that can trigger a target when an image is pushed to this

repository.

Parameters:
  • name (string) – The name of the rule
  • target (@aws-cdk/aws-events.IEventRuleTarget (optional)) – An IEventRuleTarget to invoke when this event happens (you can add more targets using addTarget)
  • imageTag (string (optional)) – Only trigger on the specific image tag
Return type:

@aws-cdk/aws-events.EventRule

Abstract:

Yes

repositoryUriForTag([tag]) → string

Returns the URI of the repository for a certain tag. Can be used in docker push/pull.

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[:TAG]
Parameters:tag (string (optional)) – Image tag to use (tools usually default to “latest” if omitted)
Return type:string
Abstract:Yes
toCodePipelineSourceAction(props) → @aws-cdk/aws-ecr.PipelineSourceAction

Convenience method for creating a new {@link PipelineSourceAction}.

Parameters:props (CommonPipelineSourceActionProps) – the construction properties of the new Action
Returns:the newly created {@link PipelineSourceAction}
Return type:PipelineSourceAction
Abstract:Yes
node

Inherited from @aws-cdk/cdk.IConstruct

The construct node in the scope tree.

Type:@aws-cdk/cdk.ConstructNode (readonly)
dependencyRoots

Inherited from @aws-cdk/cdk.IDependable

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)

LifecycleRule (interface)

class @aws-cdk/aws-ecr.LifecycleRule

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.LifecycleRule;
// LifecycleRule is an interface
import { LifecycleRule } from '@aws-cdk/aws-ecr';

An ECR life cycle rule

description

Describes the purpose of the rule

Type:string (optional)
Default:No description
maxImageAgeDays

The maximum age of images to retain

Specify exactly one of maxImageCount and maxImageAgeDays.

Type:number (optional)
maxImageCount

The maximum number of images to retain

Specify exactly one of maxImageCount and maxImageAgeDays.

Type:number (optional)
rulePriority

Controls the order in which rules are evaluated (low to high)

All rules must have a unique priority, where lower numbers have

higher precedence. The first rule that matches is applied to an image.

There can only be one rule with a tagStatus of Any, and it must have

the highest rulePriority.

All rules without a specified priority will have incrementing priorities

automatically assigned to them, higher than any rules that DO have priorities.

Type:number (optional)
Default:Automatically assigned
tagPrefixList

Select images that have ALL the given prefixes in their tag.

Only if tagStatus == TagStatus.Tagged

Type:string[] (optional)
tagStatus

Select images based on tags

Only one rule is allowed to select untagged images, and it must

have the highest rulePriority.

Type:TagStatus (optional)
Default:TagStatus.Tagged if tagPrefixList is given, TagStatus.Any otherwise

PipelineSourceAction

class @aws-cdk/aws-ecr.PipelineSourceAction(props)

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.PipelineSourceAction;
const { PipelineSourceAction } = require('@aws-cdk/aws-ecr');
import { PipelineSourceAction } from '@aws-cdk/aws-ecr';

The ECR Repository source CodePipeline Action.

Extends:@aws-cdk/aws-codepipeline-api.SourceAction
Parameters:props (PipelineSourceActionProps) –
bind(stage, _scope)

Implements @aws-cdk/aws-codepipeline-api.Action.bind()

The method called when an Action is attached to a Pipeline.

This method is guaranteed to be called only once for each Action instance.

Protected method

Parameters:
addInputArtifact(artifact) → @aws-cdk/aws-codepipeline-api.Action

Inherited from @aws-cdk/aws-codepipeline-api.Action

Protected method

Parameters:artifact (@aws-cdk/aws-codepipeline-api.Artifact) –
Return type:@aws-cdk/aws-codepipeline-api.Action
addOutputArtifact(name) → @aws-cdk/aws-codepipeline-api.Artifact

Inherited from @aws-cdk/aws-codepipeline-api.Action

Protected method

Parameters:name (string) –
Return type:@aws-cdk/aws-codepipeline-api.Artifact
onStateChange(name[, target[, options]]) → @aws-cdk/aws-events.EventRule

Inherited from @aws-cdk/aws-codepipeline-api.Action

Parameters:
Return type:

@aws-cdk/aws-events.EventRule

validate() → string[]

Inherited from @aws-cdk/aws-codepipeline-api.Action

Protected method

Return type:string[]
actionName

Inherited from @aws-cdk/aws-codepipeline-api.Action

Type:string (readonly)
category

Inherited from @aws-cdk/aws-codepipeline-api.Action

The category of the action.

The category defines which action type the owner

(the entity that performs the action) performs.

Type:@aws-cdk/aws-codepipeline-api.ActionCategory (readonly)
owner

Inherited from @aws-cdk/aws-codepipeline-api.Action

Type:string (readonly)
provider

Inherited from @aws-cdk/aws-codepipeline-api.Action

The service provider that the action calls.

Type:string (readonly)
runOrder

Inherited from @aws-cdk/aws-codepipeline-api.Action

The order in which AWS CodePipeline runs this action.

For more information, see the AWS CodePipeline User Guide.

https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#action-requirements

Type:number (readonly)
scope

Inherited from @aws-cdk/aws-codepipeline-api.Action

Retrieves the Construct scope of this Action.

Only available after the Action has been added to a Stage,

and that Stage to a Pipeline.

Protected property

Type:@aws-cdk/cdk.Construct (readonly)
version

Inherited from @aws-cdk/aws-codepipeline-api.Action

Type:string (readonly)
configuration

Inherited from @aws-cdk/aws-codepipeline-api.Action

The action’s configuration. These are key-value pairs that specify input values for an action.

For more information, see the AWS CodePipeline User Guide.

http://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#action-requirements

Type:any (optional) (readonly)
region

Inherited from @aws-cdk/aws-codepipeline-api.Action

The AWS region the given Action resides in.

Note that a cross-region Pipeline requires replication buckets to function correctly.

You can provide their names with the {@link PipelineProps#crossRegionReplicationBuckets} property.

If you don’t, the CodePipeline Construct will create new Stacks in your CDK app containing those buckets,

that you will need to cdk deploy before deploying the main, Pipeline-containing Stack.

Type:string (optional) (readonly)
Default:the Action resides in the same region as the Pipeline
role

Inherited from @aws-cdk/aws-codepipeline-api.Action

The service role that is assumed during execution of action.

This role is not mandatory, however more advanced configuration

may require specifying it.

Type:@aws-cdk/aws-iam.IRole (optional) (readonly)
outputArtifact

Inherited from @aws-cdk/aws-codepipeline-api.SourceAction

Type:@aws-cdk/aws-codepipeline-api.Artifact (readonly)

PipelineSourceActionProps (interface)

class @aws-cdk/aws-ecr.PipelineSourceActionProps

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.PipelineSourceActionProps;
// PipelineSourceActionProps is an interface
import { PipelineSourceActionProps } from '@aws-cdk/aws-ecr';

Construction properties of {@link PipelineSourceAction}.

Extends:CommonPipelineSourceActionProps
repository

The repository that will be watched for changes.

Type:IRepository
actionName

Inherited from @aws-cdk/aws-codepipeline-api.CommonActionProps

The physical, human-readable name of the Action.

Not that Action names must be unique within a single Stage.

Type:string
runOrder

Inherited from @aws-cdk/aws-codepipeline-api.CommonActionProps

The runOrder property for this Action.

RunOrder determines the relative order in which multiple Actions in the same Stage execute.

Type:number (optional)
Default:1
imageTag

Inherited from @aws-cdk/aws-ecr.CommonPipelineSourceActionProps

The image tag that will be checked for changes.

Type:string (optional)
Default:‘latest’
outputArtifactName

Inherited from @aws-cdk/aws-ecr.CommonPipelineSourceActionProps

The name of the source’s output artifact.

Output artifacts are used by CodePipeline as inputs into other actions.

Type:string (optional)
Default:a name will be auto-generated

Repository

class @aws-cdk/aws-ecr.Repository(scope, id[, props])

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.Repository;
const { Repository } = require('@aws-cdk/aws-ecr');
import { Repository } from '@aws-cdk/aws-ecr';

Define an ECR repository

Extends:

RepositoryBase

Parameters:
addLifecycleRule(rule)

Add a life cycle rule to the repository

Life cycle rules automatically expire images from the repository that match

certain conditions.

Parameters:rule (LifecycleRule) –
addToResourcePolicy(statement)

Implements @aws-cdk/aws-ecr.RepositoryBase.addToResourcePolicy()

Add a policy statement to the repository’s resource policy

Parameters:statement (@aws-cdk/aws-iam.PolicyStatement) –
export() → @aws-cdk/aws-ecr.RepositoryImportProps

Implements @aws-cdk/aws-ecr.RepositoryBase.export()

Export this repository from the stack

Return type:RepositoryImportProps
repositoryArn

Implements @aws-cdk/aws-ecr.RepositoryBase.repositoryArn()

The ARN of the repository

Type:string (readonly)
repositoryName

Implements @aws-cdk/aws-ecr.RepositoryBase.repositoryName()

The name of the repository

Type:string (readonly)
grant(identity, *actions)

Inherited from @aws-cdk/aws-ecr.RepositoryBase

Grant the given principal identity permissions to perform the actions on this repository

Parameters:
grantPull([identity])

Inherited from @aws-cdk/aws-ecr.RepositoryBase

Grant the given identity permissions to use the images in this repository

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
grantPullPush([identity])

Inherited from @aws-cdk/aws-ecr.RepositoryBase

Grant the given identity permissions to pull and push images to this repository.

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
onImagePushed(name[, target[, imageTag]]) → @aws-cdk/aws-events.EventRule

Inherited from @aws-cdk/aws-ecr.RepositoryBase

Defines an AWS CloudWatch event rule that can trigger a target when an image is pushed to this

repository.

Parameters:
  • name (string) – The name of the rule
  • target (@aws-cdk/aws-events.IEventRuleTarget (optional)) – An IEventRuleTarget to invoke when this event happens (you can add more targets using addTarget)
  • imageTag (string (optional)) – Only trigger on the specific image tag
Return type:

@aws-cdk/aws-events.EventRule

repositoryUriForTag([tag]) → string

Inherited from @aws-cdk/aws-ecr.RepositoryBase

Returns the URL of the repository. Can be used in docker push/pull.

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[:TAG]
Parameters:tag (string (optional)) – Optional image tag
Return type:string
toCodePipelineSourceAction(props) → @aws-cdk/aws-ecr.PipelineSourceAction

Inherited from @aws-cdk/aws-ecr.RepositoryBase

Convenience method for creating a new {@link PipelineSourceAction}.

Parameters:props (CommonPipelineSourceActionProps) –
Return type:PipelineSourceAction
repositoryUri

Inherited from @aws-cdk/aws-ecr.RepositoryBase

The URI of this repository (represents the latest image):

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY
Type:string (readonly)
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

RepositoryBase

class @aws-cdk/aws-ecr.RepositoryBase(scope, id)

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.RepositoryBase;
const { RepositoryBase } = require('@aws-cdk/aws-ecr');
import { RepositoryBase } from '@aws-cdk/aws-ecr';

Base class for ECR repository. Reused between imported repositories and owned repositories.

Extends:

@aws-cdk/cdk.Construct

Implements:

IRepository

Abstract:

Yes

Parameters:
  • scope (@aws-cdk/cdk.Construct) – The scope in which to define this construct
  • id (string) – The scoped construct ID. Must be unique amongst siblings. If the ID includes a path separator (/), then it will be replaced by double dash .
static arnForLocalRepository(repositoryName, scope) → string

Returns an ECR ARN for a repository that resides in the same account/region

as the current stack.

Parameters:
Return type:

string

static import(scope, id, props) → @aws-cdk/aws-ecr.IRepository

Import a repository

Parameters:
Return type:

IRepository

addToResourcePolicy(statement)

Implements @aws-cdk/aws-ecr.IRepository.addToResourcePolicy()

Add a policy statement to the repository’s resource policy

Parameters:statement (@aws-cdk/aws-iam.PolicyStatement) –
Abstract:Yes
export() → @aws-cdk/aws-ecr.RepositoryImportProps

Implements @aws-cdk/aws-ecr.IRepository.export()

Export this repository from the stack

Return type:RepositoryImportProps
Abstract:Yes
grant(identity, *actions)

Implements @aws-cdk/aws-ecr.IRepository.grant()

Grant the given principal identity permissions to perform the actions on this repository

Parameters:
grantPull([identity])

Implements @aws-cdk/aws-ecr.IRepository.grantPull()

Grant the given identity permissions to use the images in this repository

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
grantPullPush([identity])

Implements @aws-cdk/aws-ecr.IRepository.grantPullPush()

Grant the given identity permissions to pull and push images to this repository.

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) –
onImagePushed(name[, target[, imageTag]]) → @aws-cdk/aws-events.EventRule

Implements @aws-cdk/aws-ecr.IRepository.onImagePushed()

Defines an AWS CloudWatch event rule that can trigger a target when an image is pushed to this

repository.

Parameters:
  • name (string) – The name of the rule
  • target (@aws-cdk/aws-events.IEventRuleTarget (optional)) – An IEventRuleTarget to invoke when this event happens (you can add more targets using addTarget)
  • imageTag (string (optional)) – Only trigger on the specific image tag
Return type:

@aws-cdk/aws-events.EventRule

repositoryUriForTag([tag]) → string

Implements @aws-cdk/aws-ecr.IRepository.repositoryUriForTag()

Returns the URL of the repository. Can be used in docker push/pull.

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[:TAG]
Parameters:tag (string (optional)) – Optional image tag
Return type:string
toCodePipelineSourceAction(props) → @aws-cdk/aws-ecr.PipelineSourceAction

Implements @aws-cdk/aws-ecr.IRepository.toCodePipelineSourceAction()

Convenience method for creating a new {@link PipelineSourceAction}.

Parameters:props (CommonPipelineSourceActionProps) –
Return type:PipelineSourceAction
repositoryArn

Implements @aws-cdk/aws-ecr.IRepository.repositoryArn()

The ARN of the repository

Type:string (readonly) (abstract)
repositoryName

Implements @aws-cdk/aws-ecr.IRepository.repositoryName()

The name of the repository

Type:string (readonly) (abstract)
repositoryUri

Implements @aws-cdk/aws-ecr.IRepository.repositoryUri()

The URI of this repository (represents the latest image):

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY
Type:string (readonly)
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

RepositoryImportProps (interface)

class @aws-cdk/aws-ecr.RepositoryImportProps

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.RepositoryImportProps;
// RepositoryImportProps is an interface
import { RepositoryImportProps } from '@aws-cdk/aws-ecr';
repositoryArn

The ARN of the repository to import.

At least one of repositoryArn or repositoryName is required.

Type:string (optional)
Default:If you only have a repository name and the repository is in the same

account/region as the current stack, you can set repositoryName instead and the ARN will be formatted with the current region and account.

@aws-cdk/aws-ecr.repositoryName

The full name of the repository to import.

This is only needed if the repository ARN is not a concrete string, in which

case it is impossible to safely parse the ARN and extract full repository

names from it if it includes multiple components (e.g. foo/bar/myrepo).

If the repository is in the same region/account as the stack, it is sufficient

to only specify the repository name.

Type:string (optional)

RepositoryProps (interface)

class @aws-cdk/aws-ecr.RepositoryProps

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.RepositoryProps;
// RepositoryProps is an interface
import { RepositoryProps } from '@aws-cdk/aws-ecr';
lifecycleRegistryId

The AWS account ID associated with the registry that contains the repository.

Type:string (optional)
Default:The default registry is assumed.
lifecycleRules

Life cycle rules to apply to this registry

Type:LifecycleRule[] (optional)
Default:No life cycle rules
repositoryName

Name for this repository

Type:string (optional)
Default:Automatically generated name.
retain

Retain the repository on stack deletion

If you don’t set this to true, the registry must be empty, otherwise

your stack deletion will fail.

Type:boolean (optional)
Default:false

TagStatus (enum)

class @aws-cdk/aws-ecr.TagStatus

Language-specific names:

using Amazon.CDK.AWS.ECR;
import software.amazon.awscdk.services.ecr.TagStatus;
const { TagStatus } = require('@aws-cdk/aws-ecr');
import { TagStatus } from '@aws-cdk/aws-ecr';

Select images based on tags

Any

Rule applies to all images

Tagged

Rule applies to tagged images

Untagged

Rule applies to untagged images