Skip to content

Commit

Permalink
Replace use of for_each in acceptance test
Browse files Browse the repository at this point in the history
There is an open issue about how for_each loops don't work : hashicorp/terraform-plugin-sdk#536
  • Loading branch information
SarahFrench committed Jul 21, 2022
1 parent 882a1da commit c5fbd8b
Showing 1 changed file with 34 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit c5fbd8b

Please sign in to comment.