Skip to content

Commit

Permalink
feat(webhook-datasource): add enabling of Cloud pubsub API (SSPROD-45…
Browse files Browse the repository at this point in the history
…515) (#37)
  • Loading branch information
SKosier authored Sep 11, 2024
1 parent 24dce9b commit dd35f11
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/services/webhook-datasource/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ resource "google_project_iam_audit_config" "audit_config" {
}
}

#-------------------#
# Cloud Pub/Sub API #
#-------------------#

resource "google_project_service" "pubsub_api" {
project = var.project_id
service = "pubsub.googleapis.com"

disable_on_destroy = false
}

#-----------------#
# Ingestion topic #
#-----------------#
Expand All @@ -61,13 +72,17 @@ resource "google_pubsub_topic" "ingestion_topic" {
labels = var.labels
project = var.project_id
message_retention_duration = var.message_retention_duration

depends_on = [google_project_service.pubsub_api]
}

resource "google_pubsub_topic" "deadletter_topic" {
name = "dl-${google_pubsub_topic.ingestion_topic.name}"

project = var.project_id
message_retention_duration = var.message_retention_duration

depends_on = [google_project_service.pubsub_api]
}

#------#
Expand Down Expand Up @@ -105,6 +120,8 @@ resource "google_pubsub_topic_iam_member" "publisher_iam_member" {
topic = google_pubsub_topic.ingestion_topic.name
role = "roles/pubsub.publisher"
member = var.is_organizational ? google_logging_organization_sink.ingestion_sink[0].writer_identity : google_logging_project_sink.ingestion_sink[0].writer_identity

depends_on = [google_project_service.pubsub_api]
}

#-------------------#
Expand Down Expand Up @@ -156,6 +173,8 @@ resource "google_pubsub_subscription" "ingestion_topic_push_subscription" {
dead_letter_topic = google_pubsub_topic.deadletter_topic.id
max_delivery_attempts = var.max_delivery_attempts
}

depends_on = [google_project_service.pubsub_api]
}

#------------------------------------------------------------------#
Expand Down

0 comments on commit dd35f11

Please sign in to comment.