IRepository

class aws_cdk.aws_ecr.IRepository(*args, **kwargs)

Bases: IResource, Protocol

Represents an ECR repository.

Methods

add_to_resource_policy(statement)

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

Parameters:

statement (PolicyStatement) –

Return type:

AddToResourcePolicyResult

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:
Return type:

Grant

grant_pull(grantee)

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

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_pull_push(grantee)

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

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_push(grantee)

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

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_read(grantee)

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

Parameters:

grantee (IGrantable) –

Return type:

Grant

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:

Rule

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:

Rule

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:

Rule

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 the 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:

Rule

repository_uri_for_digest(digest=None)

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 (Optional[str]) – Image digest to use (tools usually default to the image with the “latest” tag if omitted).

Return type:

str

repository_uri_for_tag(tag=None)

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 (Optional[str]) – Image tag to use (tools usually default to “latest” if omitted).

Return type:

str

repository_uri_for_tag_or_digest(tag_or_digest=None)

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:

tag_or_digest (Optional[str]) – Image tag or digest to use (tools usually default to the image with the “latest” tag if omitted).

Return type:

str

Attributes

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.

repository_arn

The ARN of the repository.

Attribute:

true

repository_name

The name of the repository.

Attribute:

true

repository_uri

.

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

Attribute:

true

Type:

The URI of this repository (represents the latest image)

stack

The stack in which this resource is defined.