RepositoryBase

class aws_cdk.aws_ecr.RepositoryBase(scope, id, *, account=None, environment_from_arn=None, physical_name=None, region=None)

Bases: Resource

Base class for ECR repository.

Reused between imported repositories and owned repositories.

Parameters:
  • scope (Construct) –

  • id (str) –

  • account (Optional[str]) – The AWS account ID this resource belongs to. Default: - the resource is in the same account as the stack it belongs to

  • environment_from_arn (Optional[str]) – ARN to deduce region and account from. The ARN is parsed and the account and region are taken from the ARN. This should be used for imported resources. Cannot be supplied together with either account or region. Default: - take environment from account, region parameters, or use Stack environment.

  • physical_name (Optional[str]) – The value passed in by users to the physical name prop of the resource. - undefined implies that a physical name will be allocated by CloudFormation during deployment. - a concrete value implies a specific physical name - PhysicalName.GENERATE_IF_NEEDED is a marker that indicates that a physical will only be generated by the CDK if it is needed for cross-environment references. Otherwise, it will be allocated by CloudFormation. Default: - The physical name will be allocated by CloudFormation at deployment time

  • region (Optional[str]) – The AWS region this resource belongs to. Default: - the resource is in the same region as the stack it belongs to

Methods

abstract 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 use the 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

on_cloud_trail_event(id, *, description=None, event_pattern=None, rule_name=None, target=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.

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

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type:

Rule

on_cloud_trail_image_pushed(id, *, image_tag=None, description=None, event_pattern=None, rule_name=None, target=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

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

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type:

Rule

on_event(id, *, description=None, event_pattern=None, rule_name=None, target=None)

Defines a CloudWatch event rule which triggers for repository events.

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

Parameters:
  • id (str) –

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

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type:

Rule

on_image_scan_completed(id, *, image_tags=None, description=None, event_pattern=None, rule_name=None, target=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 spedified. Leave it undefined to watch the full repository. Default: - Watch the changes to the repository with all image tags

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

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

Return type:

Rule

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

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 construct tree node associated with this construct.

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 is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool