Skip to content

Commit 5676f7d

Browse files
authored
Support Null Label 0.24.1 (#31)
1 parent 53fccec commit 5676f7d

File tree

9 files changed

+133
-58
lines changed

9 files changed

+133
-58
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
# Cloud Posse must review any changes to standard context definition,
1717
# but some changes can be rubber-stamped.
18-
**/context.tf @cloudposse/engineering @cloudposse/approvers
19-
README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
20-
docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
18+
**/*.tf @cloudposse/engineering @cloudposse/approvers
19+
README.yaml @cloudposse/engineering @cloudposse/approvers
20+
README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
21+
docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
2122

2223
# Cloud Posse Admins must review all changes to CODEOWNERS or the mergify configuration
2324
.github/mergify.yml @cloudposse/admins

.github/workflows/auto-context.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
make init
2828
make github/init/context.tf
2929
make readme/build
30-
echo "::set-output name=create_pull_request=true"
30+
echo "::set-output name=create_pull_request::true"
3131
fi
3232
else
3333
echo "This module has not yet been updated to support the context.tf pattern! Please update in order to support automatic updates."
@@ -38,6 +38,8 @@ jobs:
3838
uses: cloudposse/actions/github/[email protected]
3939
with:
4040
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
41+
committer: 'cloudpossebot <[email protected]>'
42+
author: 'cloudpossebot <[email protected]>'
4143
commit-message: Update context.tf from origin source
4244
title: Update context.tf
4345
body: |-

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ Available targets:
425425

426426
| Name | Version |
427427
|------|---------|
428-
| terraform | >= 0.12.26 |
428+
| terraform | >= 0.13.0 |
429429
| aws | >= 2.0 |
430430
| random | >= 2.0 |
431431

@@ -496,7 +496,7 @@ Available targets:
496496
| codepipeline\_s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no |
497497
| container\_cpu | Atlantis CPUs per task | `number` | `256` | no |
498498
| container\_memory | Atlantis memory per task | `number` | `512` | no |
499-
| 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> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
499+
| 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 |
500500
| default\_backend\_image | ECS default (bootstrap) image | `string` | `"cloudposse/default-backend:0.1.2"` | no |
501501
| 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 |
502502
| desired\_count | Atlantis desired number of tasks | `number` | `1` | no |
@@ -519,9 +519,11 @@ Available targets:
519519
| github\_webhooks\_token\_ssm\_name | SSM param name to lookup `github_webhooks_token` if not provided | `string` | `""` | no |
520520
| healthcheck\_path | Healthcheck path | `string` | `"/healthz"` | no |
521521
| hostname | Atlantis URL | `string` | `""` | no |
522-
| 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 |
522+
| id\_length\_limit | Limit `id` to this many characters (minimum 6).<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 |
523523
| kms\_key\_id | KMS key ID used to encrypt SSM SecureString parameters | `string` | `""` | no |
524+
| 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 |
524525
| 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 |
526+
| 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 |
525527
| launch\_type | The ECS launch type (valid options: FARGATE or EC2) | `string` | `"FARGATE"` | no |
526528
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
527529
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |

context.tf

Lines changed: 50 additions & 16 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.22.1" // requires Terraform >= 0.12.26
23+
version = "0.24.1" # requires Terraform >= 0.13.0
2424

2525
enabled = var.enabled
2626
namespace = var.namespace
@@ -34,27 +34,16 @@ 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
}
4042

4143
# Copy contents of cloudposse/terraform-null-label/variables.tf here
4244

4345
variable "context" {
44-
type = object({
45-
enabled = bool
46-
namespace = string
47-
environment = string
48-
stage = string
49-
name = string
50-
delimiter = string
51-
attributes = list(string)
52-
tags = map(string)
53-
additional_tag_map = map(string)
54-
regex_replace_chars = string
55-
label_order = list(string)
56-
id_length_limit = number
57-
})
46+
type = any
5847
default = {
5948
enabled = true
6049
namespace = null
@@ -68,6 +57,8 @@ variable "context" {
6857
regex_replace_chars = null
6958
label_order = []
7059
id_length_limit = null
60+
label_key_case = null
61+
label_value_case = null
7162
}
7263
description = <<-EOT
7364
Single object for setting entire context at once.
@@ -76,6 +67,16 @@ variable "context" {
7667
Individual variable settings (non-null) override settings in context object,
7768
except for attributes, tags, and additional_tag_map, which are merged.
7869
EOT
70+
71+
validation {
72+
condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
73+
error_message = "Allowed values: `lower`, `title`, `upper`."
74+
}
75+
76+
validation {
77+
condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
78+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
79+
}
7980
}
8081

8182
variable "enabled" {
@@ -158,11 +159,44 @@ variable "id_length_limit" {
158159
type = number
159160
default = null
160161
description = <<-EOT
161-
Limit `id` to this many characters.
162+
Limit `id` to this many characters (minimum 6).
162163
Set to `0` for unlimited length.
163164
Set to `null` for default, which is `0`.
164165
Does not affect `id_full`.
165166
EOT
167+
validation {
168+
condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0
169+
error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length."
170+
}
171+
}
172+
173+
variable "label_key_case" {
174+
type = string
175+
default = null
176+
description = <<-EOT
177+
The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
178+
Possible values: `lower`, `title`, `upper`.
179+
Default value: `title`.
180+
EOT
181+
182+
validation {
183+
condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case)
184+
error_message = "Allowed values: `lower`, `title`, `upper`."
185+
}
166186
}
167187

188+
variable "label_value_case" {
189+
type = string
190+
default = null
191+
description = <<-EOT
192+
The letter case of output label values (also used in `tags` and `id`).
193+
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
194+
Default value: `lower`.
195+
EOT
196+
197+
validation {
198+
condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case)
199+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
200+
}
201+
}
168202
#### End of copy of cloudposse/terraform-null-label/variables.tf

docs/terraform.md

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

44
| Name | Version |
55
|------|---------|
6-
| terraform | >= 0.12.26 |
6+
| terraform | >= 0.13.0 |
77
| aws | >= 2.0 |
88
| random | >= 2.0 |
99

@@ -74,7 +74,7 @@
7474
| codepipeline\_s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no |
7575
| container\_cpu | Atlantis CPUs per task | `number` | `256` | no |
7676
| container\_memory | Atlantis memory per task | `number` | `512` | no |
77-
| 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> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
77+
| 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 |
7878
| default\_backend\_image | ECS default (bootstrap) image | `string` | `"cloudposse/default-backend:0.1.2"` | no |
7979
| 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 |
8080
| desired\_count | Atlantis desired number of tasks | `number` | `1` | no |
@@ -97,9 +97,11 @@
9797
| github\_webhooks\_token\_ssm\_name | SSM param name to lookup `github_webhooks_token` if not provided | `string` | `""` | no |
9898
| healthcheck\_path | Healthcheck path | `string` | `"/healthz"` | no |
9999
| hostname | Atlantis URL | `string` | `""` | no |
100-
| 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 |
100+
| id\_length\_limit | Limit `id` to this many characters (minimum 6).<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 |
101101
| kms\_key\_id | KMS key ID used to encrypt SSM SecureString parameters | `string` | `""` | no |
102+
| 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 |
102103
| 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 |
104+
| 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 |
103105
| launch\_type | The ECS launch type (valid options: FARGATE or EC2) | `string` | `"FARGATE"` | no |
104106
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
105107
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |

examples/complete/context.tf

Lines changed: 50 additions & 16 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.22.1" // requires Terraform >= 0.12.26
23+
version = "0.24.1" # requires Terraform >= 0.13.0
2424

2525
enabled = var.enabled
2626
namespace = var.namespace
@@ -34,27 +34,16 @@ 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
}
4042

4143
# Copy contents of cloudposse/terraform-null-label/variables.tf here
4244

4345
variable "context" {
44-
type = object({
45-
enabled = bool
46-
namespace = string
47-
environment = string
48-
stage = string
49-
name = string
50-
delimiter = string
51-
attributes = list(string)
52-
tags = map(string)
53-
additional_tag_map = map(string)
54-
regex_replace_chars = string
55-
label_order = list(string)
56-
id_length_limit = number
57-
})
46+
type = any
5847
default = {
5948
enabled = true
6049
namespace = null
@@ -68,6 +57,8 @@ variable "context" {
6857
regex_replace_chars = null
6958
label_order = []
7059
id_length_limit = null
60+
label_key_case = null
61+
label_value_case = null
7162
}
7263
description = <<-EOT
7364
Single object for setting entire context at once.
@@ -76,6 +67,16 @@ variable "context" {
7667
Individual variable settings (non-null) override settings in context object,
7768
except for attributes, tags, and additional_tag_map, which are merged.
7869
EOT
70+
71+
validation {
72+
condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
73+
error_message = "Allowed values: `lower`, `title`, `upper`."
74+
}
75+
76+
validation {
77+
condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
78+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
79+
}
7980
}
8081

8182
variable "enabled" {
@@ -158,11 +159,44 @@ variable "id_length_limit" {
158159
type = number
159160
default = null
160161
description = <<-EOT
161-
Limit `id` to this many characters.
162+
Limit `id` to this many characters (minimum 6).
162163
Set to `0` for unlimited length.
163164
Set to `null` for default, which is `0`.
164165
Does not affect `id_full`.
165166
EOT
167+
validation {
168+
condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0
169+
error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length."
170+
}
171+
}
172+
173+
variable "label_key_case" {
174+
type = string
175+
default = null
176+
description = <<-EOT
177+
The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
178+
Possible values: `lower`, `title`, `upper`.
179+
Default value: `title`.
180+
EOT
181+
182+
validation {
183+
condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case)
184+
error_message = "Allowed values: `lower`, `title`, `upper`."
185+
}
166186
}
167187

188+
variable "label_value_case" {
189+
type = string
190+
default = null
191+
description = <<-EOT
192+
The letter case of output label values (also used in `tags` and `id`).
193+
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
194+
Default value: `lower`.
195+
EOT
196+
197+
validation {
198+
condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case)
199+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
200+
}
201+
}
168202
#### End of copy of cloudposse/terraform-null-label/variables.tf

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ locals {
4040
#--------------------------------------------------------------
4141
module "ssh_key_pair" {
4242
source = "cloudposse/ssm-tls-ssh-key-pair/aws"
43-
version = "0.8.0"
43+
version = "0.10.0"
4444
ssh_private_key_name = var.ssh_private_key_name
4545
ssh_public_key_name = var.ssh_public_key_name
4646
ssm_path_prefix = var.chamber_service
@@ -51,7 +51,7 @@ module "ssh_key_pair" {
5151

5252
module "github_webhooks" {
5353
source = "cloudposse/repository-webhooks/github"
54-
version = "0.11.0"
54+
version = "0.12.0"
5555
enabled = local.enabled && var.webhook_enabled ? true : false
5656
github_organization = var.repo_owner
5757
github_repositories = [var.repo_name]
@@ -66,7 +66,7 @@ module "github_webhooks" {
6666

6767
module "ecs_web_app" {
6868
source = "cloudposse/ecs-web-app/aws"
69-
version = "0.52.0"
69+
version = "0.53.0"
7070

7171
region = var.region
7272
vpc_id = var.vpc_id

0 commit comments

Comments
 (0)