繁体   English   中英

如何使用 terraform 在 Google Cloud Platform 中创建松弛通知通道

[英]How to create a slack notification channel in Google Cloud Platform with terraform

我正在尝试使用 terraform 在 GCP 中创建一个松弛通知通道。我可以使用下面的代码创建一个通道,但它缺少“团队”和“所有者”属性。

resource "google_monitoring_notification_channel" "default" {
  display_name = "Test Slack Channel"
  type         = "slack"
  enabled      = "true"
  labels = {
    "channel_name" = "#testing"
    "auth_token"   = "<my_slack_app_token>"
  }
}

下面屏幕截图中的第一个通道是通过 GUI 创建的,并且工作正常。 第二个通道是通过 terraform 创建的,无法发送通知:松弛通道

Terraform 注册表没有提到这些属性,我尝试在channel_name之后的标签中定义它们:

labels = {
  "channel_name" = "#testing"
  "team"         = "<my_team>"
  "owner"        = "google_cloud_monitoring"
  "auth_token"   = "<my_slack_app_token>"
}

我收到以下错误:

Error creating NotificationChannel: googleapi: Error 400: Field "notification_channel.labels['owner']" is not allowed; labels must conform to the channel type's descriptor; permissible label keys for "slack" are: {"auth_token", "channel_name"}

显然,只有channel_nameauth_token是有效标签。

我错过了什么?

Slack 需要令牌的sensitive_lables选项。 文档中有一个示例

resource "google_monitoring_notification_channel" "default" {
  display_name = "Test Slack Channel"
  type         = "slack"
  labels = {
    "channel_name" = "#foobar"
  }
  sensitive_labels {
    auth_token = "...."
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM