From d6d24b80d687e76e029f39f444d0163b42c5d5e0 Mon Sep 17 00:00:00 2001 From: Maarten van der Hoef Date: Wed, 14 Aug 2019 19:43:57 +0200 Subject: [PATCH] Dropping null_resource (#80) --- README.md | 6 ++++-- README.yaml | 2 ++ examples/complete/label2.tf | 13 ++++++++++--- main.tf | 26 ++++++++++++-------------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index f3bf4a5..9668eca 100644 --- a/README.md +++ b/README.md @@ -664,8 +664,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply ### Contributors -| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]
[Sergey Vasilyev][s2504s_homepage] | [![Michael Pereira][MichaelPereira_avatar]][MichaelPereira_homepage]
[Michael Pereira][MichaelPereira_homepage] | [![Jamie Nelson][Jamie-BitFlight_avatar]][Jamie-BitFlight_homepage]
[Jamie Nelson][Jamie-BitFlight_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]
[Vladimir][SweetOps_homepage] | [![Daren Desjardins][darend_avatar]][darend_homepage]
[Daren Desjardins][darend_homepage] | -|---|---|---|---|---|---|---|---| +| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]
[Sergey Vasilyev][s2504s_homepage] | [![Michael Pereira][MichaelPereira_avatar]][MichaelPereira_homepage]
[Michael Pereira][MichaelPereira_homepage] | [![Jamie Nelson][Jamie-BitFlight_avatar]][Jamie-BitFlight_homepage]
[Jamie Nelson][Jamie-BitFlight_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]
[Vladimir][SweetOps_homepage] | [![Daren Desjardins][darend_avatar]][darend_homepage]
[Daren Desjardins][darend_homepage] | [![Maarten van der Hoef][maartenvanderhoef_avatar]][maartenvanderhoef_homepage]
[Maarten van der Hoef][maartenvanderhoef_homepage] | +|---|---|---|---|---|---|---|---|---| [osterman_homepage]: https://github.com/osterman [osterman_avatar]: https://github.com/osterman.png?size=150 @@ -683,6 +683,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply [SweetOps_avatar]: https://github.com/SweetOps.png?size=150 [darend_homepage]: https://github.com/darend [darend_avatar]: https://github.com/darend.png?size=150 + [maartenvanderhoef_homepage]: https://github.com/maartenvanderhoef + [maartenvanderhoef_avatar]: https://github.com/maartenvanderhoef.png?size=150 diff --git a/README.yaml b/README.yaml index ccd9dc1..2ef8c3e 100644 --- a/README.yaml +++ b/README.yaml @@ -509,3 +509,5 @@ contributors: github: "SweetOps" - name: "Daren Desjardins" github: "darend" + - name: "Maarten van der Hoef" + github: "maartenvanderhoef" diff --git a/examples/complete/label2.tf b/examples/complete/label2.tf index 3f23bf3..faf7450 100644 --- a/examples/complete/label2.tf +++ b/examples/complete/label2.tf @@ -6,6 +6,12 @@ module "label2" { delimiter = "+" regex_replace_chars = "/[^a-zA-Z0-9-+]/" + additional_tag_map = { + propagate_at_launch = "true" + additional_tag = "yes" + } + + tags = { "City" = "London" "Environment" = "Public" @@ -27,9 +33,10 @@ output "label2_tags" { value = module.label2.tags } +output "label2_tags_as_list_of_maps" { + value = module.label2.tags_as_list_of_maps +} + output "label2_context" { value = module.label2.context } - - - diff --git a/main.tf b/main.tf index 4c00993..4e26f96 100644 --- a/main.tf +++ b/main.tf @@ -25,8 +25,18 @@ locals { # Merge attributes attributes = compact(distinct(concat(var.attributes, var.context.attributes, local.defaults.attributes))) - tags = merge(var.context.tags, local.generated_tags, var.tags) - tags_as_list_of_maps = data.null_data_source.tags_as_list_of_maps.*.outputs + tags = merge(var.context.tags, local.generated_tags, var.tags) + + tags_as_list_of_maps_unmerged_additional_tag_map = flatten([ + for key in keys(local.tags) : { + key = key + value = local.tags[key] + }]) + + tags_as_list_of_maps = [ + for tag_set in local.tags_as_list_of_maps_unmerged_additional_tag_map : + merge(tag_set, var.additional_tag_map) + ] tags_context = { # For AWS we need `Name` to be disambiguated sine it has a special meaning @@ -67,15 +77,3 @@ locals { } } - -data "null_data_source" "tags_as_list_of_maps" { - count = local.enabled ? length(keys(local.tags)) : 0 - - inputs = merge( - { - "key" = keys(local.tags)[count.index] - "value" = values(local.tags)[count.index] - }, - var.additional_tag_map - ) -}