aws-cdk-lib.aws_ecr.LifecycleRule

interface LifecycleRule

LanguageType name
.NETAmazon.CDK.AWS.ECR.LifecycleRule
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecr#LifecycleRule
Javasoftware.amazon.awscdk.services.ecr.LifecycleRule
Pythonaws_cdk.aws_ecr.LifecycleRule
TypeScript (source)aws-cdk-lib » aws_ecr » LifecycleRule

An ECR life cycle rule.

Example

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

Properties

NameTypeDescription
description?stringDescribes the purpose of the rule.
maxImageAge?DurationThe maximum age of images to retain. The value must represent a number of days.
maxImageCount?numberThe maximum number of images to retain.
rulePriority?numberControls the order in which rules are evaluated (low to high).
tagPrefixList?string[]Select images that have ALL the given prefixes in their tag.
tagStatus?TagStatusSelect images based on tags.

description?

Type: string (optional, default: No description)

Describes the purpose of the rule.


maxImageAge?

Type: Duration (optional)

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

Specify exactly one of maxImageCount and maxImageAge.


maxImageCount?

Type: number (optional)

The maximum number of images to retain.

Specify exactly one of maxImageCount and maxImageAge.


rulePriority?

Type: number (optional, default: Automatically assigned)

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.


tagPrefixList?

Type: string[] (optional)

Select images that have ALL the given prefixes in their tag.

Only if tagStatus == TagStatus.Tagged


tagStatus?

Type: TagStatus (optional, default: TagStatus.Tagged if tagPrefixList is given, TagStatus.Any otherwise)

Select images based on tags.

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