# IRepository

Represents an ECR repository.

Extends: IRepository
Extends: IResource, IRepositoryRef
Implemented by: Repository, RepositoryBase

- Source: [`aws-ecr/lib/repository.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-ecr/lib/repository.ts#L42)
- Type last changed: v2.234.0 · 8 Jan 2026

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `registryUri`: string — The URI of this repository's registry:.

  ACCOUNT.dkr.ecr.REGION.amazonaws.com

- `repositoryArn`: string — The ARN of the repository.

- `repositoryName`: string — The name of the repository.

- `repositoryRef`: [RepositoryReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_ecr.RepositoryReference.html) — A reference to a Repository resource.

- `repositoryUri`: string — The URI of this repository (represents the latest image):.

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

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult` — Add a policy statement to the repository's resource policy.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — 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: IGrantable, ...actions: string[]): Grant` — Grant the given principal identity permissions to perform the actions on this repository.

- `grantPull(grantee: IGrantable): Grant` — Grant the given identity permissions to pull images in this repository.

- `grantPullPush(grantee: IGrantable): Grant` — Grant the given identity permissions to pull and push images to this repository.

- `grantPush(grantee: IGrantable): Grant` — Grant the given identity permissions to push images in this repository.

- `grantRead(grantee: IGrantable): Grant` — Grant the given identity permissions to read images in this repository.

- `onCloudTrailEvent(id: string, options?: OnEventOptions): 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.

  **Parameters**

  - `id` — The id of the rule.
  - `options` — Options for adding the rule.

- `onCloudTrailImagePushed(id: string, options?: OnCloudTrailImagePushedOptions): 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.

  **Parameters**

  - `id` — The id of the rule.
  - `options` — Options for adding the rule.

- `onEvent(id: string, options?: OnEventOptions): Rule` — Defines a CloudWatch event rule which triggers for repository events.

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

- `onImageScanCompleted(id: string, options?: OnImageScanCompletedOptions): Rule` — Defines an AWS CloudWatch event rule that can trigger a target when the image scan is completed.

  **Parameters**

  - `id` — The id of the rule.
  - `options` — Options for adding the rule.

- `repositoryUriForDigest(digest?: string): 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]

  **Parameters**

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

- `repositoryUriForTag(tag?: string): 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` — Image tag to use (tools usually default to "latest" if omitted).

- `repositoryUriForTagOrDigest(tagOrDigest?: string): 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]

  **Parameters**

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

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
