8
8
# Cloud Posse's standard configuration inputs suitable for passing
9
9
# to Cloud Posse modules.
10
10
#
11
+ # curl -sL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf -o context.tf
12
+ #
11
13
# Modules should access the whole context as `module.this.context`
12
14
# to get the input variables with nulls for defaults,
13
15
# for example `context = module.this.context`,
20
22
21
23
module "this" {
22
24
source = " cloudposse/label/null"
23
- version = " 0.24.1 " # requires Terraform >= 0.13.0
25
+ version = " 0.25.0 " # requires Terraform >= 0.13.0
24
26
25
27
enabled = var. enabled
26
28
namespace = var. namespace
29
+ tenant = var. tenant
27
30
environment = var. environment
28
31
stage = var. stage
29
32
name = var. name
@@ -36,6 +39,8 @@ module "this" {
36
39
id_length_limit = var. id_length_limit
37
40
label_key_case = var. label_key_case
38
41
label_value_case = var. label_value_case
42
+ descriptor_formats = var. descriptor_formats
43
+ labels_as_tags = var. labels_as_tags
39
44
40
45
context = var. context
41
46
}
@@ -47,6 +52,7 @@ variable "context" {
47
52
default = {
48
53
enabled = true
49
54
namespace = null
55
+ tenant = null
50
56
environment = null
51
57
stage = null
52
58
name = null
@@ -59,6 +65,15 @@ variable "context" {
59
65
id_length_limit = null
60
66
label_key_case = null
61
67
label_value_case = null
68
+ descriptor_formats = {}
69
+ # Note: we have to use [] instead of null for unset lists due to
70
+ # https://github.com/hashicorp/terraform/issues/28137
71
+ # which was not fixed until Terraform 1.0.0,
72
+ # but we want the default to be all the labels in `label_order`
73
+ # and we want users to be able to prevent all tag generation
74
+ # by setting `labels_as_tags` to `[]`, so we need
75
+ # a different sentinel to indicate "default"
76
+ labels_as_tags = [" unset" ]
62
77
}
63
78
description = <<- EOT
64
79
Single object for setting entire context at once.
@@ -88,69 +103,107 @@ variable "enabled" {
88
103
variable "namespace" {
89
104
type = string
90
105
default = null
91
- description = " Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
106
+ description = " ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique"
107
+ }
108
+
109
+ variable "tenant" {
110
+ type = string
111
+ default = null
112
+ description = " ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for"
92
113
}
93
114
94
115
variable "environment" {
95
116
type = string
96
117
default = null
97
- description = " Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT'"
118
+ description = " ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'"
98
119
}
99
120
100
121
variable "stage" {
101
122
type = string
102
123
default = null
103
- description = " Stage , e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'"
124
+ description = " ID element. Usually used to indicate role , e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'"
104
125
}
105
126
106
127
variable "name" {
107
128
type = string
108
129
default = null
109
- description = " Solution name, e.g. 'app' or 'jenkins'"
130
+ description = <<- EOT
131
+ ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
132
+ This is the only ID element not also included as a `tag`.
133
+ The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input.
134
+ EOT
110
135
}
111
136
112
137
variable "delimiter" {
113
138
type = string
114
139
default = null
115
140
description = <<- EOT
116
- Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` .
141
+ Delimiter to be used between ID elements .
117
142
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
118
143
EOT
119
144
}
120
145
121
146
variable "attributes" {
122
147
type = list (string )
123
148
default = []
124
- description = " Additional attributes (e.g. `1`)"
149
+ description = <<- EOT
150
+ ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
151
+ in the order they appear in the list. New attributes are appended to the
152
+ end of the list. The elements of the list are joined by the `delimiter`
153
+ and treated as a single ID element.
154
+ EOT
155
+ }
156
+
157
+ variable "labels_as_tags" {
158
+ type = set (string )
159
+ default = [" default" ]
160
+ description = <<- EOT
161
+ Set of labels (ID elements) to include as tags in the `tags` output.
162
+ Default is to include all labels.
163
+ Tags with empty values will not be included in the `tags` output.
164
+ Set to `[]` to suppress all generated tags.
165
+ **Notes:**
166
+ The value of the `name` tag, if included, will be the `id`, not the `name`.
167
+ Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
168
+ changed in later chained modules. Attempts to change it will be silently ignored.
169
+ EOT
125
170
}
126
171
127
172
variable "tags" {
128
173
type = map (string )
129
174
default = {}
130
- description = " Additional tags (e.g. `map('BusinessUnit','XYZ')`"
175
+ description = <<- EOT
176
+ Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
177
+ Neither the tag keys nor the tag values will be modified by this module.
178
+ EOT
131
179
}
132
180
133
181
variable "additional_tag_map" {
134
182
type = map (string )
135
183
default = {}
136
- description = " Additional tags for appending to tags_as_list_of_maps. Not added to `tags`."
184
+ description = <<- EOT
185
+ Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
186
+ This is for some rare cases where resources want additional configuration of tags
187
+ and therefore take a list of maps with tag key, value, and additional configuration.
188
+ EOT
137
189
}
138
190
139
191
variable "label_order" {
140
192
type = list (string )
141
193
default = null
142
194
description = <<- EOT
143
- The naming order of the id output and Name tag .
195
+ The order in which the labels (ID elements) appear in the `id` .
144
196
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
145
- You can omit any of the 5 elements , but at least one must be present.
146
- EOT
197
+ You can omit any of the 6 labels ("tenant" is the 6th) , but at least one must be present.
198
+ EOT
147
199
}
148
200
149
201
variable "regex_replace_chars" {
150
202
type = string
151
203
default = null
152
204
description = <<- EOT
153
- Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
205
+ Terraform regular expression (regex) string.
206
+ Characters matching the regex will be removed from the ID elements.
154
207
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits.
155
208
EOT
156
209
}
@@ -161,7 +214,7 @@ variable "id_length_limit" {
161
214
description = <<- EOT
162
215
Limit `id` to this many characters (minimum 6).
163
216
Set to `0` for unlimited length.
164
- Set to `null` for default , which is `0`.
217
+ Set to `null` for keep the existing setting , which defaults to `0`.
165
218
Does not affect `id_full`.
166
219
EOT
167
220
validation {
@@ -174,7 +227,8 @@ variable "label_key_case" {
174
227
type = string
175
228
default = null
176
229
description = <<- EOT
177
- The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
230
+ Controls the letter case of the `tags` keys (label names) for tags generated by this module.
231
+ Does not affect keys of tags passed in via the `tags` input.
178
232
Possible values: `lower`, `title`, `upper`.
179
233
Default value: `title`.
180
234
EOT
@@ -189,8 +243,11 @@ variable "label_value_case" {
189
243
type = string
190
244
default = null
191
245
description = <<- EOT
192
- The letter case of output label values (also used in `tags` and `id`).
246
+ Controls the letter case of ID elements (labels) as included in `id`,
247
+ set as tag values, and output by this module individually.
248
+ Does not affect values of tags passed in via the `tags` input.
193
249
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
250
+ Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
194
251
Default value: `lower`.
195
252
EOT
196
253
@@ -199,4 +256,24 @@ variable "label_value_case" {
199
256
error_message = " Allowed values: `lower`, `title`, `upper`, `none`."
200
257
}
201
258
}
259
+
260
+ variable "descriptor_formats" {
261
+ type = any
262
+ default = {}
263
+ description = <<- EOT
264
+ Describe additional descriptors to be output in the `descriptors` output map.
265
+ Map of maps. Keys are names of descriptors. Values are maps of the form
266
+ `{
267
+ format = string
268
+ labels = list(string)
269
+ }`
270
+ (Type is `any` so the map values can later be enhanced to provide additional options.)
271
+ `format` is a Terraform format string to be passed to the `format()` function.
272
+ `labels` is a list of labels, in order, to pass to `format()` function.
273
+ Label values will be normalized before being passed to `format()` so they will be
274
+ identical to how they appear in `id`.
275
+ Default is `{}` (`descriptors` output will be empty).
276
+ EOT
277
+ }
278
+
202
279
# ### End of copy of cloudposse/terraform-null-label/variables.tf
0 commit comments