Skip to content

Commit

Permalink
add support for shared vpc host to project factory (#2300)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoo authored May 22, 2024
1 parent 1e149c1 commit ef5178c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
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

0 comments on commit ef5178c

Please sign in to comment.