forked from tlc-pack/ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecr.tf
46 lines (44 loc) · 1 KB
/
ecr.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
resource "aws_ecr_repository" "ci_ecr" {
for_each = toset(var.ecr_repositories)
name = each.value
image_tag_mutability = "IMMUTABLE"
}
resource "aws_ecr_lifecycle_policy" "untagged_removal_policy" {
for_each = toset(var.ecr_repositories)
repository = aws_ecr_repository.ci_ecr[each.value].name
policy = <<EOF
{
"rules": [
{
"action": {
"type": "expire"
},
"selection": {
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 1,
"tagStatus": "tagged",
"tagPrefixList": [
"PR-"
]
},
"description": "Remove PR images",
"rulePriority": 1
},
{
"action": {
"type": "expire"
},
"selection": {
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 7,
"tagStatus": "any"
},
"description": "Remove any images older than 7 days",
"rulePriority": 2
}
]
}
EOF
}