Skip to content

Commit

Permalink
fix: use for_each for shared VPC service project connections (#329)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: shared_vpc attachments in the `fabric-net-svpc-access` submodule have been refactored, changing the state location.
  • Loading branch information
nikhilmakhijani committed Oct 21, 2021
1 parent e28f1e5 commit 3f400af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions modules/fabric-net-svpc-access/main.tf
Expand Up @@ -15,11 +15,10 @@
*/

resource "google_compute_shared_vpc_service_project" "projects" {
provider = google-beta

count = var.service_project_num
provider = google-beta
for_each = { for i, k in toset(var.service_project_ids) : k => i }
host_project = var.host_project_id
service_project = element(var.service_project_ids, count.index)
service_project = each.key
}

resource "google_compute_subnetwork_iam_binding" "network_users" {
Expand Down
4 changes: 3 additions & 1 deletion modules/fabric-net-svpc-access/outputs.tf
Expand Up @@ -16,5 +16,7 @@

output "service_projects" {
description = "Project ids of the services with access to all subnets."
value = google_compute_shared_vpc_service_project.projects.*.service_project
value = [
for i, k in google_compute_shared_vpc_service_project.projects : k.service_project
]
}

0 comments on commit 3f400af

Please sign in to comment.