|
4 | 4 | # TODO: |
5 | 5 | # Add attributes to name if not empty |
6 | 6 | # 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 | +} |
7 | 21 |
|
8 | 22 | locals { |
9 | 23 | attr = "${lower(format("%s", join(var.delimiter, compact(var.attributes))))}" |
10 | 24 | env = "${lower(format("%s", var.environment))}" |
11 | 25 | name_low = "${lower(format("%s", var.name))}" |
12 | 26 | 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}" |
15 | 29 | id = "${length(local.attr) > 0 ? join(var.delimiter, list(local.id_org, local.attr)) : local.id_org}" |
16 | 30 | id_20 = "${substr(replace(local.id,"_","-"),0,19 <= length(local.id) ? 19 : length(local.id))}" |
17 | 31 | 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 "" |
18 | 49 | tags = "${ merge( |
19 | 50 | var.tags, |
20 | 51 | map( |
|
0 commit comments