-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
62 lines (60 loc) · 1.88 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
resource "aws_ecr_repository" "default" {
name = "${var.namespace}/${var.name}"
}
resource "aws_ecr_lifecycle_policy" "default" {
repository = aws_ecr_repository.default.name
policy = jsonencode({
"rules" : concat(local.protected_images_rules, [
{
"rulePriority" : length(var.protected_images) + 1,
"description" : "Always keep ${var.max_images_count} release [${var.release_images_prefix}] images stored.",
"selection" : {
"tagStatus" : "tagged",
"tagPrefixList" : [var.release_images_prefix],
"countType" : "imageCountMoreThan",
"countNumber" : var.max_images_count
},
"action" : {
"type" : "expire"
}
},
{
"rulePriority" : length(var.protected_images) + 2,
"description" : "Always keep ${var.max_images_count} pre-release [${var.rc_images_prefix}] images stored.",
"selection" : {
"tagStatus" : "tagged",
"tagPrefixList" : [var.rc_images_prefix],
"countType" : "imageCountMoreThan",
"countNumber" : var.max_images_count
},
"action" : {
"type" : "expire"
}
},
{
"rulePriority" : length(var.protected_images) + 3,
"description" : "Remove untagged images.",
"selection" : {
"tagStatus" : "untagged",
"countType" : "imageCountMoreThan",
"countNumber" : 1
},
"action" : {
"type" : "expire"
}
},
{
"rulePriority" : length(var.protected_images) + 4,
"description" : "Remove dev images when reached ${var.max_images_count} images stored.",
"selection" : {
"tagStatus" : "any",
"countType" : "imageCountMoreThan",
"countNumber" : var.max_images_count
},
"action" : {
"type" : "expire"
}
}
])
})
}