Skip to content

Commit e03e6cf

Browse files
committed
Change to use boolean module
1 parent 7b1303d commit e03e6cf

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

main.tf

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,48 @@
44
# TODO:
55
# Add attributes to name if not empty
66
# Refactor to use local and output the locals. Test - test - test
7+
# Change where replace is done. Move to earlier in process
8+
# Create tags_asg list from tags map. If possible
9+
# New input tags_asg -> tags_asg with standard tags added
10+
11+
module "namespace-env" {
12+
source = "devops-workflow/boolean/local"
13+
version = "0.1.0"
14+
value = "${var.namespace-env}"
15+
}
16+
module "namespace-org" {
17+
source = "devops-workflow/boolean/local"
18+
version = "0.1.0"
19+
value = "${var.namespace-org}"
20+
}
721

822
locals {
923
attr = "${lower(format("%s", join(var.delimiter, compact(var.attributes))))}"
1024
env = "${lower(format("%s", var.environment))}"
1125
name_low = "${lower(format("%s", var.name))}"
1226
org = "${lower(format("%s", var.organization))}"
13-
id_env = "${var.namespace-env ? join(var.delimiter, list(local.env, local.name_low)) : local.name_low}"
14-
id_org = "${var.namespace-org ? join(var.delimiter, list(local.org, local.id_env)) : local.id_env}"
27+
id_env = "${module.namespace-env.value ? join(var.delimiter, list(local.env, local.name_low)) : local.name_low}"
28+
id_org = "${module.namespace-org.value ? join(var.delimiter, list(local.org, local.id_env)) : local.id_env}"
1529
id = "${length(local.attr) > 0 ? join(var.delimiter, list(local.id_org, local.attr)) : local.id_org}"
1630
id_20 = "${substr(replace(local.id,"_","-"),0,19 <= length(local.id) ? 19 : length(local.id))}"
1731
id_32 = "${substr(replace(local.id,"_","-"),0,31 <= length(local.id) ? 31 : length(local.id))}"
32+
/*
33+
id_attr_20= "${19 <= length(local.id) ?
34+
join(var.delimiter, substr(local.id_org,0,
35+
(19 <= length(local.id_org) ? 19 : length(local.id_org))
36+
- length(local.attr)
37+
), local.attr)
38+
: local.id}"
39+
#id_attr_32= "${19 <= length(local.id) ? local.id : }"
40+
#id_attr_20 trunc name-org then join attr - total max still 20
41+
#id_attr_32 if id >32 trunc name-org to 31 - attr, then join attr
42+
*/
43+
44+
#tags_asg list of maps
45+
#map("key", "interpolation1", "value", "value3", "propagate_at_launch", true),
46+
# keys, values, map, merge, matchkeys, transpose
47+
48+
#TODO: only add Organization if not ""
1849
tags = "${ merge(
1950
var.tags,
2051
map(

0 commit comments

Comments
 (0)