Skip to content

Commit 2de8bb4

Browse files
authored
Restore backward compatibility with v0.22.1 and earlier (#121)
1 parent 6a7c42e commit 2de8bb4

File tree

10 files changed

+135
-68
lines changed

10 files changed

+135
-68
lines changed

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are
7979

8080

8181

82+
## Security & Compliance [<img src="https://cloudposse.com/wp-content/uploads/2020/11/bridgecrew.svg" width="250" align="right" />](https://bridgecrew.io/)
83+
84+
Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance.
85+
86+
| Benchmark | Description |
87+
|--------|---------------|
88+
| [![Infrastructure Security](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/general)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=INFRASTRUCTURE+SECURITY) | Infrastructure Security Compliance |
89+
| [![CIS KUBERNETES](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/cis_kubernetes)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=CIS+KUBERNETES+V1.5) | Center for Internet Security, KUBERNETES Compliance |
90+
| [![CIS AWS](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=CIS+AWS+V1.2) | Center for Internet Security, AWS Compliance |
91+
| [![CIS AZURE](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/cis_azure)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=CIS+AZURE+V1.1) | Center for Internet Security, AZURE Compliance |
92+
| [![PCI-DSS](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/pci)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=PCI-DSS+V3.2) | Payment Card Industry Data Security Standards Compliance |
93+
| [![NIST-800-53](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/nist)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=NIST-800-53) | National Institute of Standards and Technology Compliance |
94+
| [![ISO27001](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/iso)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=ISO27001) | Information Security Management System, ISO/IEC 27001 Compliance |
95+
| [![SOC2](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/soc2)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=SOC2)| Service Organization Control 2 Compliance |
96+
| [![CIS GCP](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/cis_gcp)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=CIS+GCP+V1.1) | Center for Internet Security, GCP Compliance |
97+
| [![HIPAA](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-null-label/hipaa)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-null-label&benchmark=HIPAA) | Health Insurance Portability and Accountability Compliance |
98+
99+
100+
82101
## Usage
83102

84103

@@ -670,14 +689,14 @@ No provider.
670689
|------|-------------|------|---------|:--------:|
671690
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
672691
| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
673-
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> label_key_case = string<br> label_value_case = string<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
692+
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
674693
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
675694
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
676695
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
677696
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
678-
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`. <br>Default value: `title`. | `string` | `null` | no |
697+
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
679698
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
680-
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation). <br>Default value: `lower`. | `string` | `null` | no |
699+
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Default value: `lower`. | `string` | `null` | no |
681700
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
682701
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
683702
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |

docs/terraform.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ No provider.
1515
|------|-------------|------|---------|:--------:|
1616
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
1717
| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
18-
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> label_key_case = string<br> label_value_case = string<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
18+
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
1919
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
2020
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
2121
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
2222
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
23-
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`. <br>Default value: `title`. | `string` | `null` | no |
23+
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
2424
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
25-
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation). <br>Default value: `lower`. | `string` | `null` | no |
25+
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Default value: `lower`. | `string` | `null` | no |
2626
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
2727
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
2828
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |

examples/complete/complete.auto.tfvars

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ stage = "prd"
44
name = "null-label"
55

66
delimiter = ""
7-
id_length_limit = 6
7+
id_length_limit = 6
8+
9+
label_key_case = "lower"
10+
label_value_case = "upper"

examples/complete/context.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ module "this" {
3838
label_order = var.label_order
3939
regex_replace_chars = var.regex_replace_chars
4040
id_length_limit = var.id_length_limit
41+
label_key_case = var.label_key_case
42+
label_value_case = var.label_value_case
4143

4244
context = var.context
4345
}
@@ -188,7 +190,7 @@ variable "label_key_case" {
188190
default = null
189191
description = <<-EOT
190192
The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
191-
Possible values: `lower`, `title`, `upper`.
193+
Possible values: `lower`, `title`, `upper`.
192194
Default value: `title`.
193195
EOT
194196

@@ -203,7 +205,7 @@ variable "label_value_case" {
203205
default = null
204206
description = <<-EOT
205207
The letter case of output label values (also used in `tags` and `id`).
206-
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
208+
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
207209
Default value: `lower`.
208210
EOT
209211

@@ -212,5 +214,4 @@ variable "label_value_case" {
212214
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
213215
}
214216
}
215-
216217
#### End of copy of cloudposse/terraform-null-label/variables.tf

exports/context.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
module "this" {
2222
source = "cloudposse/label/null"
23-
version = "0.23.0" // requires Terraform >= 0.13.0
23+
version = "0.24.0" # requires Terraform >= 0.13.0
2424

2525
enabled = var.enabled
2626
namespace = var.namespace
@@ -34,6 +34,8 @@ module "this" {
3434
label_order = var.label_order
3535
regex_replace_chars = var.regex_replace_chars
3636
id_length_limit = var.id_length_limit
37+
label_key_case = var.label_key_case
38+
label_value_case = var.label_value_case
3739

3840
context = var.context
3941
}
@@ -184,7 +186,7 @@ variable "label_key_case" {
184186
default = null
185187
description = <<-EOT
186188
The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
187-
Possible values: `lower`, `title`, `upper`.
189+
Possible values: `lower`, `title`, `upper`.
188190
Default value: `title`.
189191
EOT
190192

@@ -199,7 +201,7 @@ variable "label_value_case" {
199201
default = null
200202
description = <<-EOT
201203
The letter case of output label values (also used in `tags` and `id`).
202-
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
204+
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
203205
Default value: `lower`.
204206
EOT
205207

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ locals {
77
replacement = ""
88
id_length_limit = 0
99
id_hash_length = 5
10-
label_value_case = "lower"
1110
label_key_case = "title"
11+
label_value_case = "lower"
1212
}
1313

1414
# So far, we have decided not to allow overriding replacement or id_hash_length
@@ -34,8 +34,8 @@ locals {
3434
label_order = var.label_order == null ? var.context.label_order : var.label_order
3535
regex_replace_chars = var.regex_replace_chars == null ? var.context.regex_replace_chars : var.regex_replace_chars
3636
id_length_limit = var.id_length_limit == null ? var.context.id_length_limit : var.id_length_limit
37-
label_key_case = var.label_key_case == null ? var.context.label_key_case : var.label_key_case
38-
label_value_case = var.label_value_case == null ? var.context.label_value_case : var.label_value_case
37+
label_key_case = var.label_key_case == null ? lookup(var.context, "label_key_case", null) : var.label_key_case
38+
label_value_case = var.label_value_case == null ? lookup(var.context, "label_value_case", null) : var.label_value_case
3939
}
4040

4141

test/src/examples_complete_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,16 @@ func TestExamplesComplete(t *testing.T) {
162162

163163
label6f := terraform.OutputMap(t, terraformOptions, "label6f")
164164
label6fTags := terraform.OutputMap(t, terraformOptions, "label6f_tags")
165-
assert.Equal(t, "cp~uw2~prd~null-label", label6f["id_full"])
165+
// Test of setting var.label_key_case = "lower", var.label_value_case = "upper"
166+
assert.Equal(t, "CP~UW2~PRD~NULL-LABEL", label6f["id_full"])
166167
assert.Equal(t, label6f["id_full"], label6f["id"], "id should not be truncated")
167-
assert.Equal(t, label6f["id"], label6fTags["Name"], "Name tag should match ID")
168+
assert.Equal(t, label6f["id"], label6fTags["name"], "Name tag should match ID")
168169

169170
label6t := terraform.OutputMap(t, terraformOptions, "label6t")
170171
label6tTags := terraform.OutputMap(t, terraformOptions, "label6t_tags")
171-
assert.Equal(t, "cpuw2prdnull-label", label6t["id_full"])
172+
assert.Equal(t, "CPUW2PRDNULL-LABEL", label6t["id_full"])
172173
assert.NotEqual(t, label6t["id_full"], label6t["id"], "id should be truncated")
173-
assert.Equal(t, label6t["id"], label6tTags["Name"], "Name tag should match ID")
174+
assert.Equal(t, label6t["id"], label6tTags["name"], "Name tag should match ID")
174175
assert.Equal(t, label6t["id_length_limit"], fmt.Sprintf("%d", len(label6t["id"])),
175176
"Truncated ID length should equal length limit")
176177

test/src/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module github.com/cloudposse/terraform-null-label
33
go 1.14
44

55
require (
6-
github.com/gruntwork-io/terratest v0.28.14
6+
github.com/gruntwork-io/terratest v0.31.1
77
github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494
88
github.com/stretchr/testify v1.6.1
9-
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
109
)

0 commit comments

Comments
 (0)