From faeb0d13bb324278c39e6fe3a7dba77e7983acc6 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 13 Aug 2018 17:17:06 +0200 Subject: [PATCH] MON-273 add optional extra tags support --- common/filter-tags/README.md | 1 + common/filter-tags/inputs.tf | 8 ++++++++ common/filter-tags/locals.tf | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/filter-tags/README.md b/common/filter-tags/README.md index 80ce730..033701f 100644 --- a/common/filter-tags/README.md +++ b/common/filter-tags/README.md @@ -28,6 +28,7 @@ Creates all kinds of filters tags patterns depending of the monitor type and dir | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | environment | Architecture Environment | string | - | yes | +| extra_tags | Extra optional tags | list | `` | no | | filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no | | filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | | resource | The dedicated tag for the resource | string | - | yes | diff --git a/common/filter-tags/inputs.tf b/common/filter-tags/inputs.tf index 0108baf..82d5192 100644 --- a/common/filter-tags/inputs.tf +++ b/common/filter-tags/inputs.tf @@ -17,3 +17,11 @@ variable "filter_tags_custom" { description = "Tags used for custom filtering when filter_tags_use_defaults is false" default = "*" } + +variable "extra_tags" { + description = "Extra optional tags" + type = "list" + default = [] + + # Example of value to add optional tags : ["tag1:val1", "tag2:val2"] +} diff --git a/common/filter-tags/locals.tf b/common/filter-tags/locals.tf index 4ca593a..fa392da 100644 --- a/common/filter-tags/locals.tf +++ b/common/filter-tags/locals.tf @@ -1,3 +1,3 @@ locals { - filters = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment) : "${var.filter_tags_custom}"}" + filters = "${var.filter_tags_use_defaults == "true" ? join(",", compact(concat(split(",", format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment)), compact(var.extra_tags)))) : "${var.filter_tags_custom}"}" }