From c5fbd8bf587471fea7312d9ea32f228e44eb004b Mon Sep 17 00:00:00 2001 From: Sarah French Date: Thu, 21 Jul 2022 14:50:42 +0100 Subject: [PATCH] Replace use of `for_each` in acceptance test There is an open issue about how for_each loops don't work : https://github.com/hashicorp/terraform-plugin-sdk/issues/536 --- ...source_cloudfunction2_function_test.go.erb | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/mmv1/third_party/terraform/resources/resource_cloudfunction2_function_test.go.erb b/mmv1/third_party/terraform/resources/resource_cloudfunction2_function_test.go.erb index 97e4979ae50e..5b46956d210f 100644 --- a/mmv1/third_party/terraform/resources/resource_cloudfunction2_function_test.go.erb +++ b/mmv1/third_party/terraform/resources/resource_cloudfunction2_function_test.go.erb @@ -225,20 +225,27 @@ resource "google_project" "project" { } -locals { - enabled_services = toset([ - "iam.googleapis.com", - "cloudfunctions.googleapis.com", - "eventarc.googleapis.com", - ]) +# APIs need to be activated before resources can be created +resource "google_project_service" "iam" { + provider = google-beta + project = google_project.project.project_id + service = "iam.googleapis.com" + + disable_dependent_services = true } -# APIs need to be activated before resources can be created -resource "google_project_service" "enabled_services" { - for_each = local.enabled_services +resource "google_project_service" "cloudfunctions" { + provider = google-beta + project = google_project.project.project_id + service = "cloudfunctions.googleapis.com" + + disable_dependent_services = true +} + +resource "google_project_service" "eventarc" { provider = google-beta project = google_project.project.project_id - service = each.value + service = "eventarc.googleapis.com" disable_dependent_services = true }`, context) @@ -255,20 +262,27 @@ resource "google_project" "project" { } -locals { - enabled_services = toset([ - "iam.googleapis.com", - "cloudfunctions.googleapis.com", - "eventarc.googleapis.com", - ]) +# APIs need to be activated before resources can be created +resource "google_project_service" "iam" { + provider = google-beta + project = google_project.project.project_id + service = "iam.googleapis.com" + + disable_dependent_services = true } -# APIs need to be activated before resources can be created -resource "google_project_service" "enabled_services" { - for_each = local.enabled_services +resource "google_project_service" "cloudfunctions" { + provider = google-beta + project = google_project.project.project_id + service = "cloudfunctions.googleapis.com" + + disable_dependent_services = true +} + +resource "google_project_service" "eventarc" { provider = google-beta project = google_project.project.project_id - service = each.value + service = "eventarc.googleapis.com" disable_dependent_services = true }