-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages_incoming.tf
43 lines (35 loc) · 1.1 KB
/
messages_incoming.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
resource "google_service_account" "pong_invoker" {
project = var.gcp_project_id
account_id = "awala-pong-pubsub"
display_name = "Awala Pong, Cloud Run service invoker"
}
resource "google_cloud_run_service_iam_binding" "pong_invoker" {
project = var.gcp_project_id
location = google_cloud_run_v2_service.pong.location
service = google_cloud_run_v2_service.pong.name
role = "roles/run.invoker"
members = ["serviceAccount:${google_service_account.pong_invoker.email}"]
}
resource "google_pubsub_subscription" "incoming_messages" {
project = var.gcp_project_id
name = "pong.incoming-pings"
topic = module.endpoint.pubsub_topics.incoming_messages
ack_deadline_seconds = 10
message_retention_duration = "259200s" # 3 days
retain_acked_messages = false
expiration_policy {
ttl = "" # Never expire
}
push_config {
push_endpoint = google_cloud_run_v2_service.pong.uri
oidc_token {
service_account_email = google_service_account.pong_invoker.email
}
attributes = {
x-goog-version = "v1"
}
}
retry_policy {
minimum_backoff = "5s"
}
}