-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
88 lines (78 loc) · 2.14 KB
/
variables.tf
File metadata and controls
88 lines (78 loc) · 2.14 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
variable "repository_name" {
type = string
}
variable "full_access_arns" {
type = list(string)
description = "Specific IAM users with full access to repository"
default = []
}
variable "readonly_arns" {
type = list(string)
description = "Specific IAM users with readonly access to repository"
default = []
}
variable "image_tag_mutability" {
default = "MUTABLE"
type = string
}
variable "image_scanning_configuration_scan_on_push" {
default = true
type = string
}
variable "protected_tag_prefixes" {
type = set(string)
description = "Prefixes for protected tags"
# v_ - published on a tag build
# prod_ - can be manually tagged for hotfix, or manual troubleshouting
default = ["prod_", "tag_", "v_"]
}
variable "max_repository_image_count" {
type = number
description = "Max count of images in a repo (for cost of ownership reasoning)"
default = 100
}
locals {
untagged_image_rule = [
{
rulePriority = length(var.protected_tag_prefixes) + 1
description = "Remove untagged images (tag shifted)"
selection = {
tagStatus = "untagged"
countType = "imageCountMoreThan"
countNumber = 1
}
action = {
type = "expire"
}
}]
remove_old_image_rule = [
{
rulePriority = length(var.protected_tag_prefixes) + 2
description = "Rotate images when reach ${var.max_repository_image_count} images stored",
selection = {
tagStatus = "any"
countType = "imageCountMoreThan"
countNumber = var.max_repository_image_count
}
action = {
type = "expire"
}
}]
protected_tag_rules = [
for index, tagPrefix in zipmap(range(length(var.protected_tag_prefixes)), tolist(var.protected_tag_prefixes)) :
{
rulePriority = tonumber(index) + 1
description = "Protects image tags starting with substring ${tagPrefix}"
selection = {
tagStatus = "tagged"
tagPrefixList = [
tagPrefix]
countType = "imageCountMoreThan"
countNumber = 999999
}
action = {
type = "expire"
}
}
]
}