Skip to content

Commit dea56a8

Browse files
committed
semver and id_order validation
1 parent 283aaab commit dea56a8

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ No resources.
3131
| <a name="input_attributes"></a> [attributes](#input\_attributes) | attributes, which could be used for additional attributes | `list(any)` | `[]` | no |
3232
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | delimiter, which could be used between name, namespace and env | `string` | `"-"` | no |
3333
| <a name="input_env"></a> [env](#input\_env) | environment, e.g. 'sit', 'uat', 'prod' etc | `string` | `null` | no |
34-
| <a name="input_id_order"></a> [id\_order](#input\_id\_order) | n/a | `list(any)` | <pre>[<br> "namespace",<br> "account",<br> "env",<br> "name"<br>]</pre> | no |
34+
| <a name="input_id_order"></a> [id\_order](#input\_id\_order) | The order in which the `id` is constructed. Default yields `namespace-account-env-name` if your var.delimiter is `-`. Variables that are not populated but order is preserved. Eg: If no `var.namespace` and `var.account` are not specified, yields `env-name`. | `list(any)` | <pre>[<br> "namespace",<br> "account",<br> "env",<br> "name"<br>]</pre> | no |
3535
| <a name="input_name"></a> [name](#input\_name) | stack name | `string` | `null` | no |
3636
| <a name="input_namespace"></a> [namespace](#input\_namespace) | namespace, which could be your organization name, e.g. amazon | `string` | `null` | no |
3737
| <a name="input_region"></a> [region](#input\_region) | n/a | `string` | `"us-west-1"` | no |

variable.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@ variable "tags" {
4646
}
4747

4848
variable "id_order" {
49+
description = "The order in which the `id` is constructed. Default yields `namespace-account-env-name` if your var.delimiter is `-`. Variables that are not populated but order is preserved. Eg: If no `var.namespace` and `var.account` are not specified, yields `env-name`."
4950
type = list(any)
5051
default = ["namespace", "account", "env", "name"]
51-
52+
validation {
53+
condition = anytrue([
54+
contains(var.id_order, "namespace"),
55+
contains(var.id_order, "account"),
56+
contains(var.id_order, "env"),
57+
contains(var.id_order, "name"),
58+
])
59+
error_message = "Can only contain certain values. See variables.tf."
60+
}
5261
}

versions.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ terraform {
1313

1414
provider "awscc" {
1515
user_agent = [{
16-
product_name = "terraform-aws-label"
17-
product_version = "0.0.1"
16+
product_name = "terraform-awscc-label"
17+
product_version = "0.0.4"
1818
comment = "V1/AWS-D69B4015/376222271"
1919
}]
20-
2120
}

0 commit comments

Comments
 (0)