Allow configuring project key format in project factory (#3154)

* Configurable project key in project-factory module

* Configurable project key in project-factory module

* add tests
This commit is contained in:
Ludovico Magnocavallo
2025-06-11 13:18:03 +02:00
committed by GitHub
parent 468c0ab49a
commit 7d008be2cb
18 changed files with 518 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@@ -31,10 +31,15 @@ locals {
for f in try(fileset(local._project_path, "**/*.yaml"), []) :
trimsuffix(f, ".yaml") => yamldecode(file("${local._project_path}/${f}"))
}
_projects_input = merge(
local._hierarchy_projects_full_path,
local._projects_full_path
)
_projects_input = {
for k, v in merge(
local._hierarchy_projects_full_path, local._projects_full_path
) : (
var.factories_config.projects_config.key_ignores_path == true
? basename(k)
: k
) => v
}
_project_budgets = flatten([
for k, v in local._projects_input : [
for b in try(v.billing_budgets, []) : {
@@ -48,9 +53,13 @@ locals {
data_defaults = var.data_defaults
}
projects = {
for k, v in local._projects_output : k => merge({
buckets = try(v.buckets, {})
service_accounts = try(v.service_accounts, {})
for k, v in local._projects_output : (
var.factories_config.projects_config.key_ignores_path == true
? basename(k)
: k
) => merge({
buckets = try(v.buckets, {})
service_accounts = try(v.service_accounts, {})
}, v)
}
project_budgets = {

View File

@@ -131,6 +131,8 @@ variable "data_overrides" {
variable "factories_config" {
description = "Path to folder with YAML resource description data files."
type = object({
folders_data_path = optional(string)
projects_data_path = optional(string)
budgets = optional(object({
billing_account = string
budgets_data_path = string
@@ -146,8 +148,9 @@ variable "factories_config" {
vpc_host_projects = optional(map(string), {})
notification_channels = optional(map(string), {})
}), {})
folders_data_path = optional(string)
projects_data_path = optional(string)
projects_config = optional(object({
key_ignores_path = optional(bool, false)
}), {})
})
nullable = false
}