Class Repository

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IResource, IRepository, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-12-11T23:26:32.567Z") @Stability(Stable) public class Repository extends RepositoryBase
Define an ECR repository.

Example:

 import software.amazon.awscdk.services.lambda.*;
 import software.amazon.awscdk.services.events.targets.LambdaFunction;
 Repository repo = new Repository(this, "Repo");
 Function lambdaHandler = Function.Builder.create(this, "LambdaFunction")
         .runtime(Runtime.PYTHON_3_12)
         .code(Code.fromInline("# dummy func"))
         .handler("index.handler")
         .build();
 repo.onEvent("OnEventTargetLambda", OnEventOptions.builder()
         .target(new LambdaFunction(lambdaHandler))
         .build());
 
  • Constructor Details

    • Repository

      protected Repository(software.amazon.jsii.JsiiObjectRef objRef)
    • Repository

      protected Repository(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Repository

      @Stability(Stable) public Repository(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable RepositoryProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props -
    • Repository

      @Stability(Stable) public Repository(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
  • Method Details

    • arnForLocalRepository

      @Stability(Stable) @NotNull public static String arnForLocalRepository(@NotNull String repositoryName, @NotNull software.constructs.IConstruct scope, @Nullable String account)
      Returns an ECR ARN for a repository that resides in the same account/region as the current stack.

      Parameters:
      repositoryName - This parameter is required.
      scope - This parameter is required.
      account -
    • arnForLocalRepository

      @Stability(Stable) @NotNull public static String arnForLocalRepository(@NotNull String repositoryName, @NotNull software.constructs.IConstruct scope)
      Returns an ECR ARN for a repository that resides in the same account/region as the current stack.

      Parameters:
      repositoryName - This parameter is required.
      scope - This parameter is required.
    • fromRepositoryArn

      @Stability(Stable) @NotNull public static IRepository fromRepositoryArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String repositoryArn)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      repositoryArn - This parameter is required.
    • fromRepositoryAttributes

      @Stability(Stable) @NotNull public static IRepository fromRepositoryAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull RepositoryAttributes attrs)
      Import a repository.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • fromRepositoryName

      @Stability(Stable) @NotNull public static IRepository fromRepositoryName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String repositoryName)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      repositoryName - This parameter is required.
    • addLifecycleRule

      @Stability(Stable) public void addLifecycleRule(@NotNull LifecycleRule rule)
      Add a life cycle rule to the repository.

      Life cycle rules automatically expire images from the repository that match certain conditions.

      Parameters:
      rule - This parameter is required.
    • addToResourcePolicy

      @Stability(Stable) @NotNull public AddToResourcePolicyResult addToResourcePolicy(@NotNull PolicyStatement statement)
      Add a policy statement to the repository's resource policy.

      While other resources policies in AWS either require or accept a resource section, Cfn for ECR does not allow us to specify a resource policy. It will fail if a resource section is present at all.

      Specified by:
      addToResourcePolicy in interface IRepository
      Specified by:
      addToResourcePolicy in class RepositoryBase
      Parameters:
      statement - This parameter is required.
    • getRepositoryArn

      @Stability(Stable) @NotNull public String getRepositoryArn()
      The ARN of the repository.
      Specified by:
      getRepositoryArn in interface IRepository
      Specified by:
      getRepositoryArn in class RepositoryBase
    • getRepositoryName

      @Stability(Stable) @NotNull public String getRepositoryName()
      The name of the repository.
      Specified by:
      getRepositoryName in interface IRepository
      Specified by:
      getRepositoryName in class RepositoryBase