Allow same filename in different directories
As long, as they do override default project name using `name`.
This commit is contained in:
committed by
Wiktor Niesiobędzki
parent
4769dc3dd7
commit
d63a425b62
@@ -35,7 +35,7 @@ locals {
|
|||||||
]
|
]
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
output "foo" { value = local.automation_buckets }
|
|
||||||
module "automation-bucket" {
|
module "automation-bucket" {
|
||||||
source = "../gcs"
|
source = "../gcs"
|
||||||
for_each = local.automation_buckets
|
for_each = local.automation_buckets
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
# tfdoc:file:description Projects factory locals.
|
# tfdoc:file:description Projects factory locals.
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
_hierarchy_projects = (
|
_hierarchy_projects_full_path = (
|
||||||
{
|
{
|
||||||
for f in try(fileset(local._folders_path, "**/*.yaml"), []) :
|
for f in try(fileset(local._folders_path, "**/*.yaml"), []) :
|
||||||
basename(trimsuffix(f, ".yaml")) => merge(
|
trimsuffix(f, ".yaml") => merge(
|
||||||
{ parent = dirname(f) == "." ? "default" : dirname(f) },
|
{ parent = dirname(f) == "." ? "default" : dirname(f) },
|
||||||
yamldecode(file("${local._folders_path}/${f}"))
|
yamldecode(file("${local._folders_path}/${f}"))
|
||||||
)
|
)
|
||||||
@@ -28,13 +28,16 @@ locals {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
_project_path = try(pathexpand(var.factories_config.projects_data_path), null)
|
_project_path = try(pathexpand(var.factories_config.projects_data_path), null)
|
||||||
_projects_input = merge(
|
_projects_full_path = {
|
||||||
{
|
for f in try(fileset(local._project_path, "**/*.yaml"), []) :
|
||||||
for f in try(fileset(local._project_path, "**/*.yaml"), []) :
|
trimsuffix(f, ".yaml") => yamldecode(file("${local._project_path}/${f}"))
|
||||||
basename(trimsuffix(f, ".yaml")) => yamldecode(file("${local._project_path}/${f}"))
|
}
|
||||||
},
|
_projects_input = {
|
||||||
local._hierarchy_projects
|
# will raise error, if the same filename is raised 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
|
||||||
|
}
|
||||||
_project_budgets = flatten([
|
_project_budgets = flatten([
|
||||||
for k, v in local._projects_input : [
|
for k, v in local._projects_input : [
|
||||||
for b in try(v.billing_budgets, []) : {
|
for b in try(v.billing_budgets, []) : {
|
||||||
|
|||||||
@@ -83,6 +83,124 @@ values:
|
|||||||
- group:gcp-devops@example.org
|
- group:gcp-devops@example.org
|
||||||
- group:team-a-admins@example.org
|
- group:team-a-admins@example.org
|
||||||
role: roles/viewer
|
role: roles/viewer
|
||||||
|
module.hierarchy-folder-lvl-1["team-b"].google_folder.folder[0]:
|
||||||
|
deletion_protection: false
|
||||||
|
display_name: Team B
|
||||||
|
parent: folders/5678901234
|
||||||
|
tags: null
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-a"].data.google_storage_project_service_account.gcs_sa[0]:
|
||||||
|
project: test-pf-auto-team-a
|
||||||
|
user_project: null
|
||||||
|
module.projects["auto-team-a"].google_essential_contacts_contact.contact["admin@example.org"]:
|
||||||
|
email: admin@example.org
|
||||||
|
language_tag: en
|
||||||
|
notification_category_subscriptions:
|
||||||
|
- ALL
|
||||||
|
parent: projects/test-pf-auto-team-a
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-a"].google_project.project[0]:
|
||||||
|
auto_create_network: false
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
deletion_policy: DELETE
|
||||||
|
effective_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
labels:
|
||||||
|
environment: test
|
||||||
|
name: test-pf-auto-team-a
|
||||||
|
project_id: test-pf-auto-team-a
|
||||||
|
tags: null
|
||||||
|
terraform_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-a"].google_project_iam_member.service_agents["container-engine-robot"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-auto-team-a
|
||||||
|
role: roles/container.serviceAgent
|
||||||
|
module.projects["auto-team-a"].google_project_iam_member.service_agents["gkenode"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-auto-team-a
|
||||||
|
role: roles/container.defaultNodeServiceAgent
|
||||||
|
module.projects["auto-team-a"].google_project_service.project_services["container.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-auto-team-a
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-a"].google_project_service.project_services["stackdriver.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-auto-team-a
|
||||||
|
service: stackdriver.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-a"].google_project_service.project_services["storage.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-auto-team-a
|
||||||
|
service: storage.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-a"].google_project_service_identity.default["container.googleapis.com"]:
|
||||||
|
project: test-pf-auto-team-a
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-b"].data.google_storage_project_service_account.gcs_sa[0]:
|
||||||
|
project: test-pf-auto-team-b
|
||||||
|
user_project: null
|
||||||
|
module.projects["auto-team-b"].google_essential_contacts_contact.contact["admin@example.org"]:
|
||||||
|
email: admin@example.org
|
||||||
|
language_tag: en
|
||||||
|
notification_category_subscriptions:
|
||||||
|
- ALL
|
||||||
|
parent: projects/test-pf-auto-team-b
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-b"].google_project.project[0]:
|
||||||
|
auto_create_network: false
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
deletion_policy: DELETE
|
||||||
|
effective_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
labels:
|
||||||
|
environment: test
|
||||||
|
name: test-pf-auto-team-b
|
||||||
|
project_id: test-pf-auto-team-b
|
||||||
|
tags: null
|
||||||
|
terraform_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-b"].google_project_iam_member.service_agents["container-engine-robot"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-auto-team-b
|
||||||
|
role: roles/container.serviceAgent
|
||||||
|
module.projects["auto-team-b"].google_project_iam_member.service_agents["gkenode"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-auto-team-b
|
||||||
|
role: roles/container.defaultNodeServiceAgent
|
||||||
|
module.projects["auto-team-b"].google_project_service.project_services["container.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-auto-team-b
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-b"].google_project_service.project_services["stackdriver.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-auto-team-b
|
||||||
|
service: stackdriver.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-b"].google_project_service.project_services["storage.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-auto-team-b
|
||||||
|
service: storage.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["auto-team-b"].google_project_service_identity.default["container.googleapis.com"]:
|
||||||
|
project: test-pf-auto-team-b
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
module.projects["project1"].data.google_storage_project_service_account.gcs_sa[0]:
|
module.projects["project1"].data.google_storage_project_service_account.gcs_sa[0]:
|
||||||
project: test-pf-project1
|
project: test-pf-project1
|
||||||
user_project: null
|
user_project: null
|
||||||
@@ -174,6 +292,118 @@ values:
|
|||||||
project: test-pf-project2
|
project: test-pf-project2
|
||||||
service: stackdriver.googleapis.com
|
service: stackdriver.googleapis.com
|
||||||
timeouts: null
|
timeouts: null
|
||||||
|
module.projects["project3"].data.google_storage_project_service_account.gcs_sa[0]:
|
||||||
|
project: test-pf-project3
|
||||||
|
user_project: null
|
||||||
|
module.projects["project3"].google_essential_contacts_contact.contact["admin@example.org"]:
|
||||||
|
email: admin@example.org
|
||||||
|
language_tag: en
|
||||||
|
notification_category_subscriptions:
|
||||||
|
- ALL
|
||||||
|
parent: projects/test-pf-project3
|
||||||
|
timeouts: null
|
||||||
|
module.projects["project3"].google_project.project[0]:
|
||||||
|
auto_create_network: false
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
deletion_policy: DELETE
|
||||||
|
effective_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
labels:
|
||||||
|
environment: test
|
||||||
|
name: test-pf-project3
|
||||||
|
project_id: test-pf-project3
|
||||||
|
tags: null
|
||||||
|
terraform_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
timeouts: null
|
||||||
|
module.projects["project3"].google_project_iam_member.service_agents["container-engine-robot"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-project3
|
||||||
|
role: roles/container.serviceAgent
|
||||||
|
module.projects["project3"].google_project_iam_member.service_agents["gkenode"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-project3
|
||||||
|
role: roles/container.defaultNodeServiceAgent
|
||||||
|
module.projects["project3"].google_project_service.project_services["container.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-project3
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["project3"].google_project_service.project_services["stackdriver.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-project3
|
||||||
|
service: stackdriver.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["project3"].google_project_service.project_services["storage.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-project3
|
||||||
|
service: storage.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["project3"].google_project_service_identity.default["container.googleapis.com"]:
|
||||||
|
project: test-pf-project3
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["top-project3"].data.google_storage_project_service_account.gcs_sa[0]:
|
||||||
|
project: test-pf-top-project3
|
||||||
|
user_project: null
|
||||||
|
module.projects["top-project3"].google_essential_contacts_contact.contact["admin@example.org"]:
|
||||||
|
email: admin@example.org
|
||||||
|
language_tag: en
|
||||||
|
notification_category_subscriptions:
|
||||||
|
- ALL
|
||||||
|
parent: projects/test-pf-top-project3
|
||||||
|
timeouts: null
|
||||||
|
module.projects["top-project3"].google_project.project[0]:
|
||||||
|
auto_create_network: false
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
deletion_policy: DELETE
|
||||||
|
effective_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
labels:
|
||||||
|
environment: test
|
||||||
|
name: test-pf-top-project3
|
||||||
|
project_id: test-pf-top-project3
|
||||||
|
tags: null
|
||||||
|
terraform_labels:
|
||||||
|
environment: test
|
||||||
|
goog-terraform-provisioned: 'true'
|
||||||
|
timeouts: null
|
||||||
|
module.projects["top-project3"].google_project_iam_member.service_agents["container-engine-robot"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-top-project3
|
||||||
|
role: roles/container.serviceAgent
|
||||||
|
module.projects["top-project3"].google_project_iam_member.service_agents["gkenode"]:
|
||||||
|
condition: []
|
||||||
|
project: test-pf-top-project3
|
||||||
|
role: roles/container.defaultNodeServiceAgent
|
||||||
|
module.projects["top-project3"].google_project_service.project_services["container.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-top-project3
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["top-project3"].google_project_service.project_services["stackdriver.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-top-project3
|
||||||
|
service: stackdriver.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["top-project3"].google_project_service.project_services["storage.googleapis.com"]:
|
||||||
|
disable_dependent_services: false
|
||||||
|
disable_on_destroy: false
|
||||||
|
project: test-pf-top-project3
|
||||||
|
service: storage.googleapis.com
|
||||||
|
timeouts: null
|
||||||
|
module.projects["top-project3"].google_project_service_identity.default["container.googleapis.com"]:
|
||||||
|
project: test-pf-top-project3
|
||||||
|
service: container.googleapis.com
|
||||||
|
timeouts: null
|
||||||
module.service-accounts["project1/app-be-0"].google_service_account.service_account[0]:
|
module.service-accounts["project1/app-be-0"].google_service_account.service_account[0]:
|
||||||
account_id: app-be-0
|
account_id: app-be-0
|
||||||
create_ignore_already_exists: null
|
create_ignore_already_exists: null
|
||||||
@@ -252,19 +482,19 @@ values:
|
|||||||
timeouts: null
|
timeouts: null
|
||||||
|
|
||||||
counts:
|
counts:
|
||||||
google_essential_contacts_contact: 2
|
google_essential_contacts_contact: 6
|
||||||
google_folder: 1
|
google_folder: 2
|
||||||
google_folder_iam_binding: 1
|
google_folder_iam_binding: 1
|
||||||
google_project: 2
|
google_project: 6
|
||||||
google_project_iam_member: 6
|
google_project_iam_member: 14
|
||||||
google_project_service: 4
|
google_project_service: 16
|
||||||
google_project_service_identity: 1
|
google_project_service_identity: 5
|
||||||
google_service_account: 6
|
google_service_account: 6
|
||||||
google_storage_bucket: 2
|
google_storage_bucket: 2
|
||||||
google_storage_bucket_iam_binding: 1
|
google_storage_bucket_iam_binding: 1
|
||||||
google_storage_project_service_account: 1
|
google_storage_project_service_account: 5
|
||||||
modules: 11
|
modules: 16
|
||||||
resources: 27
|
resources: 64
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
buckets:
|
buckets:
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
services:
|
||||||
|
- container.googleapis.com
|
||||||
|
- storage.googleapis.com
|
||||||
|
|
||||||
|
name: auto-team-a
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
name: Team B
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
services:
|
||||||
|
- container.googleapis.com
|
||||||
|
- storage.googleapis.com
|
||||||
|
|
||||||
|
name: auto-team-b
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
services:
|
||||||
|
- container.googleapis.com
|
||||||
|
- storage.googleapis.com
|
||||||
|
|
||||||
|
prefix: team-b
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
billing_account: 012345-67890A-BCDEF0
|
||||||
|
services:
|
||||||
|
- container.googleapis.com
|
||||||
|
- storage.googleapis.com
|
||||||
|
|
||||||
|
name: top-project3
|
||||||
|
parent: team-b
|
||||||
@@ -59,6 +59,5 @@ counts:
|
|||||||
outputs:
|
outputs:
|
||||||
buckets: {}
|
buckets: {}
|
||||||
folders: {}
|
folders: {}
|
||||||
foo: {}
|
|
||||||
projects: __missing__
|
projects: __missing__
|
||||||
service_accounts: {}
|
service_accounts: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user