英文:
How to create multiple subscriptions for a single topic in a GCP using terraform scripts
问题
resource "google_pubsub_subscription" "example-1" {
name = "example-1"
topic = "{{topic-id}}"
labels = {
application = var.app_name
business_unit = var.business_unit
contact_email = var.contact_email
name = var.app_name
owner = var.owner
}
message_retention_duration = "1200s"
retain_acked_messages = true
filter = "attributes.KEY = "value""
ack_deadline_seconds = 20
retry_policy {
minimum_backoff = "180s"
}
enable_message_ordering = true
}
英文:
Currently, I have a pub-sub topic, for which I have to create multiple subscribers which access messages published on that topic. l am using terraform scripts to create the subscription. This script is used to create a single subscriber for a topic. How can I modify the script to include multiple subscriber?
resource "google_pubsub_subscription" "example-1" {
name = "example-1"
topic = "{{topic-id}}"
labels = {
application = var.app_name
business_unit = var.business_unit
contact_email = var.contact_email
name = var.app_name
owner = var.owner
}
message_retention_duration = "1200s"
retain_acked_messages = true
filter = "attributes.KEY = \"value\""
ack_deadline_seconds = 20
retry_policy {
minimum_backoff = "180s"
}
enable_message_ordering = true
}
答案1
得分: 1
你可以使用 count。例如,要创建 3 个订阅:
resource "google_pubsub_subscription" "example" {
count = 3
name = "example-${each.key}"
topic = "{{topic-id}}"
labels = {
application = var.app_name
business_unit = var.business_unit
contact_email = var.contact_email
name = var.app_name
owner = var.owner
}
message_retention_duration = "1200s"
retain_acked_messages = true
filter = "attributes.KEY = \"value\""
ack_deadline_seconds = 20
retry_policy {
minimum_backoff = "180s"
}
enable_message_ordering = true
}
}
英文:
You can use count. For example to create 3 subscriptions:
resource "google_pubsub_subscription" "example" {
count = 3
name = "example-${each.key}"
topic = "{{topic-id}}"
labels = {
application = var.app_name
business_unit = var.business_unit
contact_email = var.contact_email
name = var.app_name
owner = var.owner
}
message_retention_duration = "1200s"
retain_acked_messages = true
filter = "attributes.KEY = \"value\""
ack_deadline_seconds = 20
retry_policy {
minimum_backoff = "180s"
}
enable_message_ordering = true
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论