Skip to content

Commit 3f400af

Browse files
fix: use for_each for shared VPC service project connections (#329)
BREAKING CHANGE: shared_vpc attachments in the `fabric-net-svpc-access` submodule have been refactored, changing the state location.
1 parent e28f1e5 commit 3f400af

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

modules/fabric-net-svpc-access/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
*/
1616

1717
resource "google_compute_shared_vpc_service_project" "projects" {
18-
provider = google-beta
19-
20-
count = var.service_project_num
18+
provider = google-beta
19+
for_each = { for i, k in toset(var.service_project_ids) : k => i }
2120
host_project = var.host_project_id
22-
service_project = element(var.service_project_ids, count.index)
21+
service_project = each.key
2322
}
2423

2524
resource "google_compute_subnetwork_iam_binding" "network_users" {

modules/fabric-net-svpc-access/outputs.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616

1717
output "service_projects" {
1818
description = "Project ids of the services with access to all subnets."
19-
value = google_compute_shared_vpc_service_project.projects.*.service_project
19+
value = [
20+
for i, k in google_compute_shared_vpc_service_project.projects : k.service_project
21+
]
2022
}

0 commit comments

Comments
 (0)