LifecycleRule

class aws_cdk.aws_ecr.LifecycleRule(*, description=None, max_image_age=None, max_image_count=None, rule_priority=None, tag_pattern_list=None, tag_prefix_list=None, tag_status=None)

Bases: object

An ECR life cycle rule.

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

ExampleMetadata:

infused

Example:

# repository: ecr.Repository

repository.add_lifecycle_rule(tag_prefix_list=["prod"], max_image_count=9999)
repository.add_lifecycle_rule(max_image_age=Duration.days(30))

Attributes

description

Describes the purpose of the rule.

Default:

No description

max_image_age

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

The maximum number of images to retain.

Specify exactly one of maxImageCount and maxImageAge.

rule_priority

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

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

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

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