aws-cdk-lib.aws_ecr.IRepository

interface IRepository

LanguageType name
.NETAmazon.CDK.AWS.ECR.IRepository
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecr#IRepository
Javasoftware.amazon.awscdk.services.ecr.IRepository
Pythonaws_cdk.aws_ecr.IRepository
TypeScript (source)aws-cdk-lib » aws_ecr » IRepository

Implemented by Repository

Obtainable from Repository.fromRepositoryArn(), Repository.fromRepositoryAttributes(), Repository.fromRepositoryName()

Represents an ECR repository.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
repositoryArnstringThe ARN of the repository.
repositoryNamestringThe name of the repository.
repositoryUristringThe URI of this repository (represents the latest image):.
stackStackThe stack in which this resource is defined.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


repositoryArn

Type: string

The ARN of the repository.


repositoryName

Type: string

The name of the repository.


repositoryUri

Type: string

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

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
addToResourcePolicy(statement)Add a policy statement to the repository's resource policy.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
grant(grantee, ...actions)Grant the given principal identity permissions to perform the actions on this repository.
grantPull(grantee)Grant the given identity permissions to pull images in this repository.
grantPullPush(grantee)Grant the given identity permissions to pull and push images to this repository.
grantPush(grantee)Grant the given identity permissions to push images in this repository.
grantRead(grantee)Grant the given identity permissions to read images in this repository.
onCloudTrailEvent(id, options?)Define a CloudWatch event that triggers when something happens to this repository.
onCloudTrailImagePushed(id, options?)Defines an AWS CloudWatch event rule that can trigger a target when an image is pushed to this repository.
onEvent(id, options?)Defines a CloudWatch event rule which triggers for repository events.
onImageScanCompleted(id, options?)Defines an AWS CloudWatch event rule that can trigger a target when the image scan is completed.
repositoryUriForDigest(digest?)Returns the URI of the repository for a certain digest. Can be used in docker push/pull.
repositoryUriForTag(tag?)Returns the URI of the repository for a certain tag. Can be used in docker push/pull.
repositoryUriForTagOrDigest(tagOrDigest?)Returns the URI of the repository for a certain tag or digest, inferring based on the syntax of the tag.

addToResourcePolicy(statement)

public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult

Parameters

  • statement PolicyStatement

Returns

  • AddToResourcePolicyResult

Add a policy statement to the repository's resource policy.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


grant(grantee, ...actions)

public grant(grantee: IGrantable, ...actions: string[]): Grant

Parameters

  • grantee IGrantable
  • actions string

Returns

  • Grant

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


grantPull(grantee)

public grantPull(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

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


grantPullPush(grantee)

public grantPullPush(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

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


grantPush(grantee)

public grantPush(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

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


grantRead(grantee)

public grantRead(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

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


onCloudTrailEvent(id, options?)

public onCloudTrailEvent(id: string, options?: OnEventOptions): Rule

Parameters

  • id string — The id of the rule.
  • options OnEventOptions — Options for adding the rule.

Returns

  • Rule

Define a CloudWatch event that triggers when something happens to this repository.

Requires that there exists at least one CloudTrail Trail in your account that captures the event. This method will not create the Trail.


onCloudTrailImagePushed(id, options?)

public onCloudTrailImagePushed(id: string, options?: OnCloudTrailImagePushedOptions): Rule

Parameters

  • id string — The id of the rule.
  • options OnCloudTrailImagePushedOptions — Options for adding the rule.

Returns

  • Rule

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

Requires that there exists at least one CloudTrail Trail in your account that captures the event. This method will not create the Trail.


onEvent(id, options?)

public onEvent(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines a CloudWatch event rule which triggers for repository events.

Use rule.addEventPattern(pattern) to specify a filter.


onImageScanCompleted(id, options?)

public onImageScanCompleted(id: string, options?: OnImageScanCompletedOptions): Rule

Parameters

  • id string — The id of the rule.
  • options OnImageScanCompletedOptions — Options for adding the rule.

Returns

  • Rule

Defines an AWS CloudWatch event rule that can trigger a target when the image scan is completed.


repositoryUriForDigest(digest?)

public repositoryUriForDigest(digest?: string): string

Parameters

  • digest string — Image digest to use (tools usually default to the image with the "latest" tag if omitted).

Returns

  • string

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

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[@DIGEST]


repositoryUriForTag(tag?)

public repositoryUriForTag(tag?: string): string

Parameters

  • tag string — Image tag to use (tools usually default to "latest" if omitted).

Returns

  • 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]


repositoryUriForTagOrDigest(tagOrDigest?)

public repositoryUriForTagOrDigest(tagOrDigest?: string): string

Parameters

  • tagOrDigest string — Image tag or digest to use (tools usually default to the image with the "latest" tag if omitted).

Returns

  • string

Returns the URI of the repository for a certain tag or digest, inferring based on the syntax of the tag.

Can be used in docker push/pull.

ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[:TAG] ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[@DIGEST]