我为我的警报创建了一个通知通道:
resource "google_monitoring_notification_channel" "slack_notification_channel" {
display_name = "${var.project_name_prefix}-notification-channel"
type = "pubsub"
labels = {
topic = "${var.pubsub_topic_name}"
}
}公共和订阅者:
resource "google_pubsub_topic" "pubsub_topic" {
name = "${var.pubsub_topic_name}"
}
resource "google_pubsub_subscription" "pubsub_subscription" {
name = "${var.project_name_prefix}-subscription"
topic = "${var.pubsub_topic_name}"
ack_deadline_seconds = 10
push_config {
push_endpoint = "${var.push_endpoint_link}"
attributes = {
x-goog-version = "v1"
}
}
}主题名称:“develop alerts-topic”。terraform输出的问题(在手册中,我创建了主题easy):
googleapi: Error 400: Field notification_channel.labels[topic] had an invalid value of "develop-alerts-topic": Value does not match the regular expression "projects/[^/]+/topics/[^/]+".你能帮助我理解为什么我得到一个错误(但所有元素被创建)的问题吗?
发布于 2020-05-05 19:33:10
你必须重用你的主题定义
resource "google_pubsub_topic" "pubsub_topic" {
name = "${var.pubsub_topic_name}"
}在您的订阅定义中,如下所示
resource "google_pubsub_subscription" "pubsub_subscription" {
name = "${var.project_name_prefix}-subscription"
# Reuse the definition of your topic. and get the name
topic = google_pubsub_topic.pubsub_topic.name
ack_deadline_seconds = 10
push_config {
push_endpoint = "${var.push_endpoint_link}"
attributes = {
x-goog-version = "v1"
}
}
}您在the documentation中有一个示例
https://stackoverflow.com/questions/61607378
复制相似问题