Repository
- class aws_cdk.aws_ecr.Repository(scope, id, *, auto_delete_images=None, empty_on_delete=None, encryption=None, encryption_key=None, image_scan_on_push=None, image_tag_mutability=None, image_tag_mutability_exclusion_filters=None, lifecycle_registry_id=None, lifecycle_rules=None, removal_policy=None, repository_name=None)
- Bases: - RepositoryBase- Define an ECR repository. - ExampleMetadata:
- infused 
 - Example: - repository = ecr.Repository(self, "TestRepository", repository_name="test-agent-runtime" ) agent_runtime_artifact = agentcore.AgentRuntimeArtifact.from_ecr_repository(repository, "v1.0.0") runtime = agentcore.Runtime(self, "MyAgentRuntime", runtime_name="myAgent", agent_runtime_artifact=agent_runtime_artifact, authorizer_configuration=agentcore.RuntimeAuthorizerConfiguration.using_oAuth("https://github.com/.well-known/openid-configuration", "oauth_client_123") ) - Parameters:
- scope ( - Construct)
- id ( - str)
- auto_delete_images ( - Optional[- bool]) – (deprecated) Whether all images should be automatically deleted when the repository is removed from the stack or when the stack is deleted. Requires the- removalPolicyto be set to- RemovalPolicy.DESTROY. Default: false
- empty_on_delete ( - Optional[- bool]) – If true, deleting the repository force deletes the contents of the repository. If false, the repository must be empty before attempting to delete it. Default: false
- encryption ( - Optional[- RepositoryEncryption]) – The kind of server-side encryption to apply to this repository. If you choose KMS, you can specify a KMS key via- encryptionKey. If encryptionKey is not specified, an AWS managed KMS key is used. Default: -- KMSif- encryptionKeyis specified, or- AES256otherwise.
- encryption_key ( - Optional[- IKeyRef]) – External KMS key to use for repository encryption. The ‘encryption’ property must be either not specified or set to “KMS”. An error will be emitted if encryption is set to “AES256”. Default: - If encryption is set to- KMSand this property is undefined, an AWS managed KMS key is used.
- image_scan_on_push ( - Optional[- bool]) – Enable the scan on push when creating the repository. Default: false
- image_tag_mutability ( - Optional[- TagMutability]) – The tag mutability setting for the repository. If this parameter is omitted, the default setting of MUTABLE will be used which will allow image tags to be overwritten. Default: TagMutability.MUTABLE
- image_tag_mutability_exclusion_filters ( - Optional[- Sequence[- ImageTagMutabilityExclusionFilter]]) – The image tag mutability exclusion filters for the repository. These filters specify which image tags can override the repository’s default image tag mutability setting. Default: undefined - AWS ECR default is no exclusion filters
- lifecycle_registry_id ( - Optional[- str]) – The AWS account ID associated with the registry that contains the repository. Default: The default registry is assumed.
- lifecycle_rules ( - Optional[- Sequence[- Union[- LifecycleRule,- Dict[- str,- Any]]]]) – Life cycle rules to apply to this registry. Default: No life cycle rules
- removal_policy ( - Optional[- RemovalPolicy]) – Determine what happens to the repository when the resource/stack is deleted. Default: RemovalPolicy.Retain
- repository_name ( - Optional[- str]) – Name for this repository. The repository name must start with a letter and can only contain lowercase letters, numbers, hyphens, underscores, and forward slashes. .. epigraph:: If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name. Default: Automatically generated name.
 
 - Methods - add_lifecycle_rule(*, description=None, max_image_age=None, max_image_count=None, rule_priority=None, tag_pattern_list=None, tag_prefix_list=None, tag_status=None)
- Add a life cycle rule to the repository. - Life cycle rules automatically expire images from the repository that match certain conditions. - Parameters:
- description ( - Optional[- str]) – Describes the purpose of the rule. Default: No description
- max_image_age ( - Optional[- Duration]) – The maximum age of images to retain. The value must represent a number of days. Specify exactly one of maxImageCount and maxImageAge.
- max_image_count ( - Union[- int,- float,- None]) – The maximum number of images to retain. Specify exactly one of maxImageCount and maxImageAge.
- rule_priority ( - Union[- int,- float,- None]) – 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. Default: Automatically assigned
- tag_pattern_list ( - Optional[- Sequence[- str]]) – Select images that have ALL the given patterns in their tag. There is a maximum limit of four wildcards (*) per string. For example, [”test*1*2*3”, “test*1*2*3”] is valid but [“test*1*2*3*4*5*6”] is invalid. Both tagPrefixList and tagPatternList cannot be specified together in a rule. Only if tagStatus == TagStatus.Tagged
- tag_prefix_list ( - Optional[- Sequence[- str]]) – Select images that have ALL the given prefixes in their tag. Both tagPrefixList and tagPatternList cannot be specified together in a rule. Only if tagStatus == TagStatus.Tagged
- tag_status ( - Optional[- TagStatus]) – Select images based on tags. Only one rule is allowed to select untagged images, and it must have the highest rulePriority. Default: TagStatus.Tagged if tagPrefixList or tagPatternList is given, TagStatus.Any otherwise
 
- Return type:
- None
 
 - add_to_resource_policy(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. - Parameters:
- statement ( - PolicyStatement)
- Return type:
 
 - apply_removal_policy(policy)
- 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).- Parameters:
- policy ( - RemovalPolicy)
- Return type:
- None
 
 - grant(grantee, *actions)
- Grant the given principal identity permissions to perform the actions on this repository. - Parameters:
- grantee ( - IGrantable)
- actions ( - str)
 
- Return type:
 
 - grant_pull(grantee)
- Grant the given identity permissions to use the images in this repository. - Parameters:
- grantee ( - IGrantable)
- Return type:
 
 - grant_pull_push(grantee)
- Grant the given identity permissions to pull and push images to this repository. - Parameters:
- grantee ( - IGrantable)
- Return type:
 
 - grant_push(grantee)
- Grant the given identity permissions to use the images in this repository. - Parameters:
- grantee ( - IGrantable)
- Return type:
 
 - grant_read(grantee)
- Grant the given identity permissions to read the images in this repository. - Parameters:
- grantee ( - IGrantable)
- Return type:
 
 - on_cloud_trail_event(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)
- 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 ( - str) – The id of the rule.
- target ( - Optional[- IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use- addTarget()to add a target.
- cross_stack_scope ( - Optional[- Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)
- description ( - Optional[- str]) – A description of the rule’s purpose. Default: - No description
- event_pattern ( - Union[- EventPattern,- Dict[- str,- Any],- None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.
- rule_name ( - Optional[- str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.
 
- Return type:
 
 - on_cloud_trail_image_pushed(id, *, image_tag=None, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)
- 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 ( - str) – The id of the rule.
- image_tag ( - Optional[- str]) – Only watch changes to this image tag. Default: - Watch changes to all tags
- target ( - Optional[- IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use- addTarget()to add a target.
- cross_stack_scope ( - Optional[- Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)
- description ( - Optional[- str]) – A description of the rule’s purpose. Default: - No description
- event_pattern ( - Union[- EventPattern,- Dict[- str,- Any],- None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.
- rule_name ( - Optional[- str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.
 
- Return type:
 
 - on_event(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)
- Defines a CloudWatch event rule which triggers for repository events. - Use - rule.addEventPattern(pattern)to specify a filter.- Parameters:
- id ( - str)
- target ( - Optional[- IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use- addTarget()to add a target.
- cross_stack_scope ( - Optional[- Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)
- description ( - Optional[- str]) – A description of the rule’s purpose. Default: - No description
- event_pattern ( - Union[- EventPattern,- Dict[- str,- Any],- None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.
- rule_name ( - Optional[- str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.
 
- Return type:
 
 - on_image_scan_completed(id, *, image_tags=None, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)
- Defines an AWS CloudWatch event rule that can trigger a target when an image scan is completed. - Parameters:
- id ( - str) – The id of the rule.
- image_tags ( - Optional[- Sequence[- str]]) – Only watch changes to the image tags specified. Leave it undefined to watch the full repository. Default: - Watch the changes to the repository with all image tags
- target ( - Optional[- IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use- addTarget()to add a target.
- cross_stack_scope ( - Optional[- Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)
- description ( - Optional[- str]) – A description of the rule’s purpose. Default: - No description
- event_pattern ( - Union[- EventPattern,- Dict[- str,- Any],- None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.
- rule_name ( - Optional[- str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.
 
- Return type:
 
 - repository_uri_for_digest(digest=None)
- Returns the URL of the repository. Can be used in - docker push/pull.- ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[@DIGEST] - Parameters:
- digest ( - Optional[- str]) – Optional image digest.
- Return type:
- str
 
 - repository_uri_for_tag(tag=None)
- Returns the URL of the repository. Can be used in - docker push/pull.- ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[:TAG] - Parameters:
- tag ( - Optional[- str]) – Optional image tag.
- Return type:
- str
 
 - repository_uri_for_tag_or_digest(tag_or_digest=None)
- Returns the URL of the repository. Can be used in - docker push/pull.- ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[:TAG] ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY[@DIGEST] - Parameters:
- tag_or_digest ( - Optional[- str]) – Optional image tag or digest (digests must start with- sha256:).
- Return type:
- str
 
 - to_string()
- Returns a string representation of this construct. - Return type:
- str
 
 - Attributes - PROPERTY_INJECTION_ID = 'aws-cdk-lib.aws-ecr.Repository'
 - env
- 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
- The tree node. 
 - registry_uri
- . - ACCOUNT.dkr.ecr.REGION.amazonaws.com - Type:
- The URI of this repository’s registry 
 
 - repository_arn
- The ARN of the repository. 
 - repository_name
- The name of the repository. 
 - repository_uri
- . - ACCOUNT.dkr.ecr.REGION.amazonaws.com/REPOSITORY - Type:
- The URI of this repository (represents the latest image) 
 
 - stack
- The stack in which this resource is defined. 
 - Static Methods - classmethod arn_for_local_repository(repository_name, scope, account=None)
- Returns an ECR ARN for a repository that resides in the same account/region as the current stack. - Parameters:
- repository_name ( - str)
- scope ( - IConstruct)
- account ( - Optional[- str])
 
- Return type:
- str
 
 - classmethod from_lookup(scope, id, *, repository_arn=None, repository_name=None)
- Lookup an existing repository. - Parameters:
- scope ( - Construct)
- id ( - str)
- repository_arn ( - Optional[- str]) – The ARN of the repository. Default: - Do not filter on repository ARN
- repository_name ( - Optional[- str]) – The name of the repository. Default: - Do not filter on repository name
 
- Return type:
 
 - classmethod from_repository_arn(scope, id, repository_arn)
- Parameters:
- scope ( - Construct)
- id ( - str)
- repository_arn ( - str)
 
- Return type:
 
 - classmethod from_repository_attributes(scope, id, *, repository_arn, repository_name)
- Import a repository. - Parameters:
- scope ( - Construct)
- id ( - str)
- repository_arn ( - str)
- repository_name ( - str)
 
- Return type:
 
 - classmethod from_repository_name(scope, id, repository_name)
- Parameters:
- scope ( - Construct)
- id ( - str)
- repository_name ( - str)
 
- Return type:
 
 - classmethod is_construct(x)
- Checks if - xis a construct.- Use this method instead of - instanceofto properly detect- Constructinstances, even when the construct library is symlinked.- Explanation: in JavaScript, multiple copies of the - constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the class- Constructin each copy of the- constructslibrary is seen as a different class, and an instance of one class will not test as- instanceofthe other class.- npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the- constructslibrary can be accidentally installed, and- instanceofwill behave unpredictably. It is safest to avoid using- instanceof, and using this type-testing method instead.- Parameters:
- x ( - Any) – Any object.
- Return type:
- bool
- Returns:
- true if - xis an object created from a class which extends- Construct.
 
 - classmethod is_owned_resource(construct)
- Returns true if the construct was created by CDK, and false otherwise. - Parameters:
- construct ( - IConstruct)
- Return type:
- bool
 
 - classmethod is_resource(construct)
- Check whether the given construct is a Resource. - Parameters:
- construct ( - IConstruct)
- Return type:
- bool