Skip to content
v2.276.0

LifecycleRule Struct ​

An ECR life cycle rule.

Example ​

ts
declare const repository: ecr.Repository;
repository.addLifecycleRule({ tagPrefixList: ['prod'], maxImageCount: 9999 });
repository.addLifecycleRule({ maxImageAge: Duration.days(30) });

Properties ​

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#
Describes the purpose of the rule.

Default: No description

maxImageAgeoptionalDurationmax_image_ageoptionalDurationmaxImageAgeoptionalDurationMaxImageAgeoptionalDurationMaxImageAgeoptionalDuration#
The maximum age of images to retain. The value must represent a number of days.

Specify exactly one of maxImageCount and maxImageAge.

maxImageCountoptionalnumbermax_image_countoptionalint | floatmaxImageCountoptionalNumberMaxImageCountoptionaldoubleMaxImageCountoptional*float64#
The maximum number of images to retain.

Specify exactly one of maxImageCount and maxImageAge.

rulePriorityoptionalnumberrule_priorityoptionalint | floatrulePriorityoptionalNumberRulePriorityoptionaldoubleRulePriorityoptional*float64#
Controls the order in which rules are evaluated (low to high).

Default: Automatically assigned

notes

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.

tagPatternListoptionalstring[]tag_pattern_listoptionaltyping.List[str]tagPatternListoptionalList<String>TagPatternListoptionalstring[]TagPatternListoptional*[]*string#
Select images that have ALL the given patterns in their tag.
notes

There is a maximum limit of four wildcards () per string. For example, ["test123", "test123*"] is valid but ["test123456"] is invalid.

Both tagPrefixList and tagPatternList cannot be specified together in a rule.

Only if tagStatus == TagStatus.Tagged

tagPrefixListoptionalstring[]tag_prefix_listoptionaltyping.List[str]tagPrefixListoptionalList<String>TagPrefixListoptionalstring[]TagPrefixListoptional*[]*string#
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

tagStatusoptionalTagStatustag_statusoptionalTagStatustagStatusoptionalTagStatusTagStatusoptionalTagStatusTagStatusoptionalTagStatus#
Select images based on tags.

Default: TagStatus.Tagged if tagPrefixList or tagPatternList is given, TagStatus.Any otherwise

Only one rule is allowed to select untagged images, and it must have the highest rulePriority.