diff --git a/README.yaml b/README.yaml index aad62a4..c0241b2 100644 --- a/README.yaml +++ b/README.yaml @@ -41,8 +41,5 @@ usage : |- environment = "test" label_order = ["name", "environment"] attributes = ["private"] - extra_tags = { - Application = "test" - } } ``` \ No newline at end of file diff --git a/_examples/complete/example.tf b/_examples/complete/example.tf index 5007d76..5ced485 100644 --- a/_examples/complete/example.tf +++ b/_examples/complete/example.tf @@ -11,7 +11,4 @@ module "labels" { environment = "test" label_order = ["name", "environment"] attributes = ["private"] - extra_tags = { - Application = "test" - } } \ No newline at end of file diff --git a/main.tf b/main.tf index e3f24d5..7803f8d 100644 --- a/main.tf +++ b/main.tf @@ -2,17 +2,12 @@ #Description : This terraform module is designed to generate consistent label names and tags #for resources. You can use terraform-labels to implement a strict naming convention. locals { - label_order_defaults = { - label_order = ["name", "environment"] - } - enabled = var.enabled == true ? true : false id_context = { name = var.name environment = var.environment } - label_order = length(var.label_order) > 0 ? var.label_order : local.label_order_defaults.label_order # run loop for label order and set in value. id_labels = [for l in var.label_order : local.id_context[l] if length(local.id_context[l]) > 0] @@ -20,19 +15,6 @@ locals { name = local.enabled == true ? lower(format("%v%s", "Name:-", var.name)) : "" environment = local.enabled == true ? lower(format("%v%s", "Environment:-", var.environment)) : "" managedby = local.enabled == true ? lower(format("%v%s", "Managedby:-", var.managedby)) : "" - attributes = local.enabled == true ? lower(format("%v", join(var.delimiter, compact(var.attributes)))) : "" - delimiter = local.enabled == true ? lower(format("%v%s", "delimiter:-", var.delimiter)) : "" - - tags_context = { - # For digitalocean we need `Name` to be disambiguated sine it has a special meaning - name = local.id - environment = local.environment - managedby = local.managedby - } - generated_tags = { for l in keys(local.tags_context) : title(l) => local.tags_context[l] if length(local.tags_context[l]) > 0 } - - tags = merge(local.generated_tags, var.extra_tags) - } ##----------------------------------------------------------------------------- diff --git a/outputs.tf b/outputs.tf index f252013..d862acf 100644 --- a/outputs.tf +++ b/outputs.tf @@ -3,21 +3,21 @@ # for resources. You can use terraform-labels to implement a strict naming # convention. output "id" { - value = join("", digitalocean_tag.id.*.id) + value = [for labels in digitalocean_tag.id : digitalocean_tag.id] description = "Disambiguated ID." } output "name" { - value = join("", digitalocean_tag.name.*.name) + value = [for labels in digitalocean_tag.name : digitalocean_tag.name] description = "Normalized name." } output "environment" { - value = join("", digitalocean_tag.environment.*.id) + value = [for labels in digitalocean_tag.environment : digitalocean_tag.environment] description = "Normalized environment." } output "managedby" { - value = join("", digitalocean_tag.managedby.*.id) + value = [for labels in digitalocean_tag.managedby : digitalocean_tag.managedby] description = "Normalized managedby." } \ No newline at end of file diff --git a/variables.tf b/variables.tf index 71475eb..5bed986 100644 --- a/variables.tf +++ b/variables.tf @@ -24,12 +24,6 @@ variable "attributes" { description = "Additional attributes (e.g. `1`)." } -variable "tags" { - type = map(string) - default = {} - description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)." -} - variable "managedby" { type = string default = "terraform-do-modules" @@ -46,10 +40,4 @@ variable "delimiter" { type = string default = "-" description = "Delimiter to be used between `organization`, `name`, `environment` and `attributes`." -} - -variable "extra_tags" { - type = map(string) - default = {} - description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)." } \ No newline at end of file