Skip to content

Commit

Permalink
feat(api): eventarc SAs
Browse files Browse the repository at this point in the history
  • Loading branch information
audronFS committed Sep 14, 2023
1 parent fc86d9d commit 40f1096
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion gcp/cloud-run-v2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ module "lb-http" {
}
}


resource "google_eventarc_trigger" "default" {
for_each = { for i, trigger in var.eventarc_triggers : i => trigger }

Expand All @@ -225,6 +224,26 @@ resource "google_eventarc_trigger" "default" {
}
}

resource "google_project_iam_binding" "eventarc_cloud_run" {
count = length(var.eventarc_triggers) > 0 && var.cloud_run_service_account != null && var.cloud_run_service_account != "" ? 1 : 0
project = var.project_id
role = "roles/eventarc.eventReceiver"

members = [
"serviceAccount:${var.cloud_run_service_account}",
]
}

resource "google_project_iam_binding" "eventarc_pubsub" {
count = length(var.eventarc_triggers) > 0 ? 1 : 0
project = var.project_id
role = "roles/iam.serviceAccountTokenCreator"

members = [
"serviceAccount:service-${var.project_id}@gcp-sa-pubsub.iam.gserviceaccount.com"
]
}

# Cloud Build trigger configuration
module "trigger_provision" {
count = var.create_trigger == true ? 1 : 0
Expand Down

0 comments on commit 40f1096

Please sign in to comment.