File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ The service is behind a load balancer which means it is exposed. A HTTP healthch
50
50
| cooldown | n/a | ` number ` | ` 60 ` | no |
51
51
| cpu | CPU reservation for the task | ` number ` | ` 256 ` | no |
52
52
| deregistration\_ delay | n/a | ` number ` | ` 30 ` | no |
53
- | ecr\_ tag\_ prefix\_ list | n/a | ` list ` | ` ["! latest"] ` | no |
53
+ | ecr\_ tag\_ prefix\_ list | n/a | ` list ` | ` ["latest"] ` | no |
54
54
| ecr_number\_ of\_ newest_tags | n/a | ` number ` | ` 90 ` | no |
55
55
| ecr\_ untagged\_ lifetime | n/a | ` number ` | ` 1 ` | no |
56
56
| environment | n/a | ` list ` | ` [] ` | no |
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ resource "aws_ecr_repository" "application" {
10
10
}
11
11
12
12
resource "aws_ecr_lifecycle_policy" "application" {
13
- count = var. image == " " ? 1 : 0
13
+ count = var. image == " " ? 1 : 0
14
14
repository = aws_ecr_repository. application [0 ]. name
15
15
16
16
policy = jsonencode ({
@@ -30,12 +30,24 @@ resource "aws_ecr_lifecycle_policy" "application" {
30
30
},
31
31
{
32
32
rulePriority = 2
33
- description = " Expire tagged images and keep last ${ var . ecr_number_of_newest_tags } "
33
+ description = " Keep important tags safe. "
34
34
selection = {
35
35
tagStatus = " tagged"
36
36
tagPrefixList = var.ecr_tag_prefix_list
37
- countType = " imageCountMoreThan"
38
- countNumber = var.ecr_number_of_newest_tags
37
+ countType = " imageCountMoreThan"
38
+ countNumber = 10000
39
+ }
40
+ action = {
41
+ type = " expire"
42
+ }
43
+ },
44
+ {
45
+ rulePriority = 3
46
+ description = " Expire tagged images and keep last ${ var . ecr_number_of_newest_tags } "
47
+ selection = {
48
+ tagStatus = " tagged"
49
+ countType = " imageCountMoreThan"
50
+ countNumber = var.ecr_number_of_newest_tags
39
51
}
40
52
action = {
41
53
type = " expire"
@@ -44,7 +56,7 @@ resource "aws_ecr_lifecycle_policy" "application" {
44
56
]
45
57
})
46
58
47
- depends_on = [ aws_ecr_repository . application ]
59
+ depends_on = [aws_ecr_repository . application ]
48
60
}
49
61
50
62
output "ecr_repository" {
Original file line number Diff line number Diff line change @@ -309,6 +309,6 @@ variable "ecr_number_of_newest_tags" {
309
309
}
310
310
311
311
variable "ecr_tag_prefix_list" {
312
- default = [" ! latest" ]
312
+ default = [" latest" ]
313
313
type = list (string )
314
314
}
You can’t perform that action at this time.
0 commit comments