Skip to content

Commit 7b1303d

Browse files
committed
Expose all variables
1 parent 9a0a0af commit 7b1303d

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ locals {
1212
org = "${lower(format("%s", var.organization))}"
1313
id_env = "${var.namespace-env ? join(var.delimiter, list(local.env, local.name_low)) : local.name_low}"
1414
id_org = "${var.namespace-org ? join(var.delimiter, list(local.org, local.id_env)) : local.id_env}"
15-
id = "${local.id_org}"
15+
id = "${length(local.attr) > 0 ? join(var.delimiter, list(local.id_org, local.attr)) : local.id_org}"
1616
id_20 = "${substr(replace(local.id,"_","-"),0,19 <= length(local.id) ? 19 : length(local.id))}"
1717
id_32 = "${substr(replace(local.id,"_","-"),0,31 <= length(local.id) ? 31 : length(local.id))}"
1818
tags = "${ merge(

outputs.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ output "id_32" {
1919
description = "ID truncated to 32 characters"
2020
value = "${local.id_32}"
2121
}
22+
output "id_env" {
23+
description = "If env namespace enabled <env>-<name> else <name>"
24+
value = "${local.id_env}"
25+
}
26+
output "id_org" {
27+
description = "If org namespace enabled <org>-<id_env> else <id_env>"
28+
value = "${local.id_org}"
29+
}
2230
output "name" {
2331
description = "Name lowercase"
2432
value = "${local.name_low}"
@@ -28,5 +36,6 @@ output "organization" {
2836
value = "${local.org}"
2937
}
3038
output "tags" {
31-
value = "${local.tags}"
39+
description = "Tags map merged with standard tags"
40+
value = "${local.tags}"
3241
}

test/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "labels" {
55
environment = "Dev"
66
organization = "CorpXyZ"
77
namespace-org = true
8-
attributes = ["role", "policy", "use", ""]
8+
#attributes = ["role", "policy", "use", ""]
99
tags = "${map("Key", "Value")}"
1010
}
1111
module "labels-tags" {

test/outputs.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ output "id_32" {
2222
description = "Name truncated to 32 characters"
2323
value = "${module.labels.id_32}"
2424
}
25+
output "id_env" {
26+
description = "If env namespace enabled <env>-<name> else <name>"
27+
value = "${module.labels.id_env}"
28+
}
29+
output "id_org" {
30+
description = "If org namespace enabled <org>-<id_env> else <id_env>"
31+
value = "${module.labels.id_org}"
32+
}
2533
output "organization" {
2634
description = "Organization name lowercase"
2735
value = "${module.labels.organization}"

0 commit comments

Comments
 (0)