Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jul 30, 2025
1 parent c180345 commit a42063f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions tags/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ output "tags" {
description = "Map of processed tag key/value pairs"
value = merge(
local.legacy_tags_remaining,
{ for k,v in local.legacy_finops_converted: format("%v_%v", local._finops_tags.prefix, k) => v },
{ for k, v in local.legacy_finops_converted : format("%v_%v", local._finops_tags.prefix, k) => v },
{ for k, v in local.finops_tags : format("%v_%v", local._finops_tags.prefix, k) => v },
)
}
Expand All @@ -18,15 +18,15 @@ output "tag_hierarchy" {

output "finops_roles" {
description = "Map of finops_project_role values based on finops_project_name and finops.roles in YAML"
value = { for r in local.finops_roles : r => { (format("%v_%v_role", local._finops_tags.prefix, "project")) = format("%v_%v", local.finops_tags.project_name, r) } }
value = { for r in local.finops_roles : r => { (format("%v_%v_role", local._finops_tags.prefix, "project")) = format("%v_%v", local.finops_tags.project_name, r) } }
}

output "finops_tags" {
pescription = "Map of finops tags by short name for individual selection"
value = { for k,v in local.finops_tags : replace(k,"${local._finops_tags.prefix}_","") => { k = v }}
description = "Map of finops tags by short name for individual selection"
value = { for k, v in local.finops_tags : replace(k, "${local._finops_tags.prefix}_", "") => { k = v } }
}

output "version" {
description = "Module version information. Cannot be passed back in tags because it will overwrite other module tags"
value = local.base_tags
value = local.base_tags
}
6 changes: 3 additions & 3 deletions tags/tags.finops.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ locals {
project_name = try(replace(local._finops.name, "/[^a-z0-9_]/", ""), null)
project_role = local._finops.role != null ? replace(replace(local._finops.role, "+", format("%v_", local._finops.name)), "/[^a-z0-9_]/", "") : null
}
finops_tags = { for k, v in local._finops_tags : k => v if v != null && k != "prefix" }
finops_roles = [for r in lookup(local.tags_in.finops,"roles",[]): lower(r) ]
finops_tags = { for k, v in local._finops_tags : k => v if v != null && k != "prefix" }
finops_roles = [for r in lookup(local.tags_in.finops, "roles", []) : lower(r)]
}

resource "terraform_data" "finops" {
Expand All @@ -28,7 +28,7 @@ resource "terraform_data" "finops_roles" {

lifecycle {
precondition {
condition = !anytrue([for r in tolist(local.finops_roles): length(regexall("[^0-9a-z_]",r)) > 0 ])
condition = !anytrue([for r in tolist(local.finops_roles) : length(regexall("[^0-9a-z_]", r)) > 0])
error_message = "Error in one of the finops.roles fields. Each value may contain only 0-9, a-z, and underscore."
}
}
Expand Down
12 changes: 6 additions & 6 deletions tags/tags.legacy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ locals {
project_name = ["Project Name", "ProjectName"]
project_role = ["Project Role", "ProjectRole"]
}
legacy_finops_tags_map = { for k, v in transpose(local.legacy_finops_tags) : k => v[0] }
legacy_finops_tags_keys = flatten([ for k, v in local.legacy_finops_tags: v ])
legacy_finops_tags_map = { for k, v in transpose(local.legacy_finops_tags) : k => v[0] }
legacy_finops_tags_keys = flatten([for k, v in local.legacy_finops_tags : v])

_legacy_finops1 = [for k, v in var.legacy_tags : { legacy_key = k, value = v, key = lookup(local.legacy_finops_tags_map, k, null) }]
legacy_finops_converted = merge([for t in local._legacy_finops1 : { (t.key) = lower(t.value) } if t.key != null]...)
legacy_tags_remaining = { for k,v in var.legacy_tags: k => v if !contains(local.legacy_finops_tags_keys,k) }
legacy_tags_remaining = { for k, v in var.legacy_tags : k => v if !contains(local.legacy_finops_tags_keys, k) }
}

resource "terraform_data" "legacy_finops_number" {
count = lookup(local.legacy_finops_converted,"project_number",null) != null ? 1 : 0
input = lookup(local.legacy_finops_converted,"project_number",null)
count = lookup(local.legacy_finops_converted, "project_number", null) != null ? 1 : 0
input = lookup(local.legacy_finops_converted, "project_number", null)

lifecycle {
precondition {
condition = length(regexall("^fs\\d{10}$",local.legacy_finops_converted["project_number"])) > 0
condition = length(regexall("^fs\\d{10}$", local.legacy_finops_converted["project_number"])) > 0
error_message = "Invalid legacy finops project_number format."
}
}
Expand Down
20 changes: 10 additions & 10 deletions tags/tags.map.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
# * like comm, but but commercial db from ec2 instance to rds

locals {
# _map_present = try(local.tags_in.map, false)
map_id = "MSDNVLIJDZ"
# _map_present = try(local.tags_in.map, false)
map_id = "MSDNVLIJDZ"
map_tag = "map-migrated"
map_values = {
"standard" = format("mig%v",local.map_id)
"ec2_standard" = format("mig_ec2_%v",local.map_id)
"commercial_db" = format("comm%v",local.map_id)
"ec2_commercial_db" = format("comm_ec2_%v",local.map_id)
"oracle" = format("oracle%v",local.map_id)
"standard" = format("mig%v", local.map_id)
"ec2_standard" = format("mig_ec2_%v", local.map_id)
"commercial_db" = format("comm%v", local.map_id)
"ec2_commercial_db" = format("comm_ec2_%v", local.map_id)
"oracle" = format("oracle%v", local.map_id)
}
}

# access these as module.tags.map_tags["commercial_db"]
output "map_tags" {
description = "Map of AWS Migration Acceleration Program (MAP) tags by usage. See https://s3.us-west-2.amazonaws.com/map-2.0-customer-documentation/html/AWSMapDocs/Examples.html for more information."
value = { for k,v in local.map_values: k => { (local.map_tag) = v } }
description = "Map of AWS Migration Acceleration Program (MAP) tags by usage. See https://s3.us-west-2.amazonaws.com/map-2.0-customer-documentation/html/AWSMapDocs/Examples.html for more information."
value = { for k, v in local.map_values : k => { (local.map_tag) = v } }
}

output "map" {
description = "Standard AWS Migration Acceleration Program (MAP) tag"
value = { (local.map_tag) = local.map_values.standard }
value = { (local.map_tag) = local.map_values.standard }
}

0 comments on commit a42063f

Please sign in to comment.