-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q2.tf
48 lines (45 loc) · 1.21 KB
/
Q2.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
#
## Q2
# this is in answer to Q2 to include ECR policy for deleting
# images older than 60 days but the last 20 images are kept regardless
# so the role for keeping 2 images has higher priority
#
resource "aws_ecr_repository" "houly_ecr_repo" {
name = "houly_ecr_repo5"
}
resource "aws_ecr_lifecycle_policy" "houly_ecr_lifecycle_policy" {
repository = "${aws_ecr_repository.houly_ecr_repo.name}"
policy = <<EOF
{
"rules": [
{
"rulePriority": 1,
"description": "Keep last 20 images",
"selection": {
"tagStatus": "any",
"countType": "imageCountMoreThan",
"countUnit": "days",
"countNumber": 20
},
"action": {
"type": "expire"
}
},
{
"rulePriority": 2,
"description": "remove images older than 60",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": "any",
"countType": "sinceImagePushed",
"countNumber": 60,
"countUnit": "days"
},
"action": {
"type": "expire"
}
}
]
}
EOF
}