So I've got a common module that has:
module "foo1" {
source = "./modules/bar"
name = "foo1"
id = "123"
}
module "foo2" {
source = "./modules/bar"
name = "foo2"
id = "456"
}
// module bar
resource "google_service_account" "service_account" {
account_id = var.name
...
}
that is being referenced by 2 other modules as you can see above. The thing is this module bar generates a resource with an email: google_service_account.service_account.email that I'd like to use to create a bunch of other resources but I only want to create them for foo1 and not for foo2 (bar module uses both name and id vars to generate the email). How can I exclude foo2 from creating resource from?
// needs to be created using the email generated for `foo1` only
resource "google_project_iam_member" "admin" {
...
member = "serviceAccount:${google_service_account.service_account.email}"
}