[ECR life cycle policy] Support to define a list of tagPrefix

0

Hi AWS Team,

I want to create an ECR lifecycle policy rule that has the following condition:

  • Keep at least 1 image if it contains a tag as "main" or "latest" or "master"

I tried to put them into: "tagPrefixList": ["main", "master", "latest"] and it seems not work in my case. :(

Do I need to create 3 separated rules for each tag? But I think it's not the best way to do. Is there any way if AWS can use OR condition if user provides a tag prefix list?

Thank you

Dy Le
asked 5 months ago253 views
2 Answers
0
Accepted Answer

This is supported as follows.


Tag prefix list

tagPrefixList
Type: list[string]

Required: yes, only if tagStatus is set to tagged

Only used if you specified "tagStatus": "tagged". 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 as prod, prod1, prod2, and so on, you would use the tag prefix prod to specify all of them. If you specify multiple tags, only the images with all specified tags are selected.

Ensure you also set the tagStatus to tagged also. Try main, master, latest without any square brackets which is what we usually use to define a list in TF.

https://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html#lp_tag_prefix_list

profile picture
EXPERT
answered 5 months ago
0

Thank you. It works perfectly! :)

Dy Le
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions