-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
175 lines (145 loc) · 4.21 KB
/
variables.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
variable "name" {
type = string
default = ""
description = "(Required) Name of the repository"
}
variable "encryption" {
type = object({
type = string
kms_key = optional(string)
})
default = {
type = "AES256"
kms_key = ""
}
description = "(Optional) Encryption configuration of the repository. Default AES256"
validation {
condition = contains(["AES256", "KMS"], var.encryption.type)
error_message = "The encryption type must be one of: AES256 or KMS."
}
}
variable "image_tag_mutability" {
type = string
default = "IMMUTABLE"
description = "(Optional) The tag mutability setting for the repository. Must be one of: MUTABLE or IMMUTABLE. Defaults to IMMUTABLE."
validation {
condition = contains(["MUTABLE", "IMMUTABLE"], var.image_tag_mutability)
error_message = "The image tag mutability must be one of: MUTABLE or IMMUTABLE."
}
}
variable "force_delete" {
type = bool
default = false
description = "(Optional) If true, will delete the repository even if it contains images. Defaults to false"
}
variable "scan_on_push" {
type = bool
default = true
description = "Indicates whether images are scanned after being pushed to the repository (true) or not scanned (false). Defauls to true"
}
## Lifecycle policy
variable "lifecycle_policy" {
type = object({
rules = list(object({
rulePriority = number
description = optional(string)
selection = object({
tagStatus = string
countType = string
countNumber = number
countUnit = string
tagPrefixList = optional(list(string))
}),
action = object({
type = string
})
}))
})
default = {
rules = []
}
description = "(Optional) A lifecycle policy for the repository. Default is empty"
validation {
condition = alltrue([
for rule in var.lifecycle_policy.rules : contains(
["tagged", "untagged", "any"],
rule.selection.tagStatus
)
])
error_message = "The tag status must be one of: tagged, untagged or any."
}
validation {
condition = alltrue([
for rule in var.lifecycle_policy.rules : contains(
["sinceImagePushed", "sinceImageCreated"],
rule.selection.countType
)
])
error_message = "The count type must be one of: sinceImagePushed or sinceImageCreated."
}
validation {
condition = alltrue([
for rule in var.lifecycle_policy.rules : contains(
["days", "weeks", "months"],
rule.selection.countUnit
)
])
error_message = "The count unit must be one of: days, weeks or months."
}
validation {
condition = alltrue([
for rule in var.lifecycle_policy.rules : rule.selection.countNumber > 0
])
error_message = "The count number must be greater than 0."
}
validation {
condition = alltrue([
for rule in var.lifecycle_policy.rules : rule.rulePriority > 0
])
error_message = "The priority must be greater than 0."
}
validation {
condition = alltrue([
for rule in var.lifecycle_policy.rules : contains(
["expire"],
rule.action.type
)
])
error_message = "The action type must be one of: expire."
}
}
## Tags
variable "tags" {
type = map(string)
default = {}
description = "A map of tags to add to resources"
}
variable "registry_scanning_configuration" {
type = object({
scan_type = string
rules = optional(list(object({
scan_frequency = string
repository_filter = object({
filter = string
})
})))
})
default = {
scan_type = "BASIC"
rules = []
}
description = "The registry scanning configuration"
validation {
condition = contains(["ENHANCED", "BASIC"], var.registry_scanning_configuration.scan_type)
error_message = "The scan type must be one of: ENHANCED or BASIC."
}
validation {
condition = alltrue([
for rule in var.registry_scanning_configuration.rules : contains(
["SCAN_ON_PUSH", "CONTINUOUS_SCAN", "MANUAL"],
rule.scan_frequency
)
])
error_message = "The scan frequency must be one of: SCAN_ON_PUSH, CONTINUOUS_SCAN or MANUAL."
}
}