Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for shared vpc host to project factory #2300

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/project-factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ module "project-factory" {
projects_data_path = "data/projects"
}
}
# tftest modules=16 resources=55 files=prj-app-1,prj-app-2,prj-app-3,budget-test-100,h-0-0,h-1-0,h-0-1,h-1-1,h-1-1-p0 inventory=example.yaml
# tftest modules=16 resources=56 files=prj-app-1,prj-app-2,prj-app-3,budget-test-100,h-0-0,h-1-0,h-0-1,h-1-1,h-1-1-p0 inventory=example.yaml
```

A simple hierarchy of folders:
Expand Down Expand Up @@ -326,6 +326,8 @@ iam:
- rw
"roles/viewer":
- ro
shared_vpc_host_config:
enabled: true
automation:
project: bar-baz-iac-0
service_accounts:
Expand Down
8 changes: 8 additions & 0 deletions modules/project-factory/factory-projects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ locals {
try(v.services, null),
var.data_defaults.services
)
shared_vpc_host_config = (
try(v.shared_vpc_host_config, null) != null
? merge(
{ service_projects = [] },
v.shared_vpc_host_config
)
: null
)
shared_vpc_service_config = (
try(v.shared_vpc_service_config, null) != null
? merge(
Expand Down
1 change: 1 addition & 0 deletions modules/project-factory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module "projects" {
each.value.services,
var.data_merges.services
))
shared_vpc_host_config = each.value.shared_vpc_host_config
shared_vpc_service_config = each.value.shared_vpc_service_config
tag_bindings = merge(
each.value.tag_bindings,
Expand Down
3 changes: 2 additions & 1 deletion tests/modules/project_factory/examples/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ values:

counts:
google_billing_budget: 1
google_compute_shared_vpc_host_project: 1
google_compute_shared_vpc_service_project: 1
google_compute_subnetwork_iam_member: 3
google_essential_contacts_contact: 4
Expand All @@ -132,4 +133,4 @@ counts:
google_storage_bucket_iam_binding: 2
google_storage_project_service_account: 4
modules: 16
resources: 55
resources: 56
Loading