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

fix: Add shared_vpc features to root module back #446

Merged
merged 10 commits into from
Dec 11, 2020
11 changes: 11 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ module "project-factory" {
vpc_service_control_perimeter_name = var.vpc_service_control_perimeter_name
}

/******************************************
Setting API service accounts for shared VPC
*****************************************/
module "shared_vpc_access" {
source = "./modules/shared_vpc_access"
host_project_id = var.shared_vpc
askoriy marked this conversation as resolved.
Show resolved Hide resolved
service_project_id = module.project-factory.project_id
active_apis = module.project-factory.enabled_apis
shared_vpc_subnets = var.shared_vpc_subnets
}

/******************************************
Billing budget to create if amount is set
*****************************************/
Expand Down
4 changes: 2 additions & 2 deletions modules/shared_vpc_access/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ resource "google_compute_subnetwork_iam_member" "service_shared_vpc_subnet_users
if "dataflow.googleapis.com" compute.networkUser role granted to dataflow service account for Dataflow on shared VPC Project if no subnets defined
*****************************************/
resource "google_project_iam_member" "service_shared_vpc_user" {
for_each = length(var.shared_vpc_subnets) == 0 ? local.active_apis : []
for_each = (length(var.shared_vpc_subnets) == 0) && (var.host_project_id != "") ? local.active_apis : []
bharathkkb marked this conversation as resolved.
Show resolved Hide resolved
project = var.host_project_id
role = "roles/compute.networkUser"
member = format("serviceAccount:%s", local.apis[each.value])
Expand All @@ -72,7 +72,7 @@ resource "google_project_iam_member" "service_shared_vpc_user" {
See:https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-shared-vpc
*****************************************/
resource "google_project_iam_member" "gke_host_agent" {
count = local.gke_shared_vpc_enabled ? 1 : 0
count = local.gke_shared_vpc_enabled && (var.host_project_id != "") ? 1 : 0
project = var.host_project_id
role = "roles/container.hostServiceAgentUser"
member = format("serviceAccount:%s", local.apis["container.googleapis.com"])
Expand Down