Use path as keys in project factory
This commit is contained in:
committed by
Wiktor Niesiobędzki
parent
8b9979d93e
commit
086fe2c914
@@ -180,9 +180,9 @@ locals {
|
||||
try(v.metric_scopes, null),
|
||||
local.__projects_config.data_defaults.metric_scopes
|
||||
)
|
||||
name = lookup(v, "name", k) # type: string
|
||||
org_policies = try(v.org_policies, {}) # type: map(object({...}))
|
||||
parent = try( # type: string, nullable
|
||||
name = lookup(v, "name", basename(k)) # type: string
|
||||
org_policies = try(v.org_policies, {}) # type: map(object({...}))
|
||||
parent = try( # type: string, nullable
|
||||
coalesce(
|
||||
local.__projects_config.data_overrides.parent,
|
||||
try(v.parent, null),
|
||||
@@ -272,4 +272,11 @@ locals {
|
||||
)
|
||||
})
|
||||
}
|
||||
# tflint-ignore: terraform_unused_declarations
|
||||
_projects_uniqunees_validation = {
|
||||
# will raise error, if the same project (derived from file name, or provided in the YAML file)
|
||||
# is sued more than once
|
||||
for k, v in local._projects_output :
|
||||
v.name => k
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,9 +180,9 @@ locals {
|
||||
try(v.metric_scopes, null),
|
||||
local.__projects_config.data_defaults.metric_scopes
|
||||
)
|
||||
name = lookup(v, "name", k) # type: string
|
||||
org_policies = try(v.org_policies, {}) # type: map(object({...}))
|
||||
parent = try( # type: string, nullable
|
||||
name = lookup(v, "name", basename(k)) # type: string
|
||||
org_policies = try(v.org_policies, {}) # type: map(object({...}))
|
||||
parent = try( # type: string, nullable
|
||||
coalesce(
|
||||
local.__projects_config.data_overrides.parent,
|
||||
try(v.parent, null),
|
||||
@@ -272,4 +272,11 @@ locals {
|
||||
)
|
||||
})
|
||||
}
|
||||
# tflint-ignore: terraform_unused_declarations
|
||||
_projects_uniqunees_validation = {
|
||||
# will raise error, if the same project (derived from file name, or provided in the YAML file)
|
||||
# is sued more than once
|
||||
for k, v in local._projects_output :
|
||||
v.name => k
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,8 @@ locals {
|
||||
for f in try(fileset(local._project_path, "**/*.yaml"), []) :
|
||||
trimsuffix(f, ".yaml") => yamldecode(file("${local._project_path}/${f}"))
|
||||
}
|
||||
_projects_input = {
|
||||
# will raise error, if the same filename is used multiple times
|
||||
# and project name is not set via name in YAML
|
||||
for k, v in merge(local._hierarchy_projects_full_path, local._projects_full_path) :
|
||||
lookup(v, "name", basename(k)) => v
|
||||
}
|
||||
|
||||
_projects_input = merge(local._hierarchy_projects_full_path, local._projects_full_path)
|
||||
_project_budgets = flatten([
|
||||
for k, v in local._projects_input : [
|
||||
for b in try(v.billing_budgets, []) : {
|
||||
|
||||
@@ -37,7 +37,7 @@ module "projects" {
|
||||
source = "../project"
|
||||
for_each = local.projects
|
||||
billing_account = each.value.billing_account
|
||||
name = each.key
|
||||
name = each.value.name
|
||||
parent = lookup(
|
||||
local.context.folder_ids, each.value.parent, each.value.parent
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user