Lifecycle policy properties in Amazon ECR
Lifecycle policies have the following properties.
To see examples of lifecycle policies, see Examples of lifecycle policies in Amazon ECR. For instructions about creating a lifecycle policy by using the Amazon CLI, see To create a lifecycle policy (Amazon CLI).
Rule priority
rulePriority-
Type: integer
Required: yes
Sets the order in which rules are applied, lowest to highest. A lifecycle policy rule with a priority of
1is applied first, a rule with priority of2is next, and so on. When you add rules to a lifecycle policy, you must give them each a unique value forrulePriority. Values don't need to be sequential across rules in a policy. A rule with atagStatusvalue ofanymust have the highest value forrulePriorityand be evaluated last.
Description
description-
Type: string
Required: no
(Optional) Describes the purpose of a rule within a lifecycle policy.
Tag status
tagStatus-
Type: string
Required: yes
Determines whether the lifecycle policy rule that you are adding specifies a tag for an image. Acceptable options are
tagged,untagged, orany. If you specifyany, then all images have the rule evaluated against them. If you specifytagged, then you must also specify atagPrefixListvalue. If you specifyuntagged, then you must omittagPrefixList.
Tag pattern list
tagPatternList-
Type: list[string]
Required: yes, if
tagStatusis set to tagged andtagPrefixListisn't specifiedWhen creating a lifecycle policy for tagged images, it's best practice to use a
tagPatternListto specify the tags to expire. You specify a comma-separated list of image tag patterns that may contain wildcards (*) on which to take action with your lifecycle policy. For example, if your images are tagged asprod,prod1,prod2, and so on, you would use the tag pattern listprod*to specify all of them. If you specify multiple tags, only the images with all specified tags are selected.Important
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.
Tag prefix list
tagPrefixList-
Type: list[string]
Required: yes, if
tagStatusis set to tagged andtagPatternListisn't specifiedOnly used if you specified
"tagStatus": "tagged"and you aren't specifying atagPatternList. You must specify a comma-separated list of image tag prefixes on which to take action with your lifecycle policy. For example, if your images are tagged asprod,prod1,prod2, and so on, you would use the tag prefixprodto specify all of them. If you specify multiple tags, only the images with all specified tags are selected.
Count type
countType-
Type: string
Required: yes
Specify a count type to apply to the images.
If
countTypeis set toimageCountMoreThan, you also specifycountNumberto create a rule that sets a limit on the number of images that exist in your repository. IfcountTypeis set tosinceImagePushed, you also specifycountUnitandcountNumberto specify a time limit on the images that exist in your repository.
Count unit
countUnit-
Type: string
Required: yes, only if
countTypeis set tosinceImagePushedSpecify a count unit of
daysto indicate that as the unit of time, in addition tocountNumber, which is the number of days.This should only be specified when
countTypeissinceImagePushed; an error will occur if you specify a count unit whencountTypeis any other value.
Count number
countNumber-
Type: integer
Required: yes
Specify a count number. Acceptable values are positive integers (
0is not an accepted value).If the
countTypeused isimageCountMoreThan, then the value is the maximum number of images that you want to retain in your repository. If thecountTypeused issinceImagePushed, then the value is the maximum age limit for your images.
Action
type-
Type: string
Required: yes
Specify an action type. The supported value is
expire.