简体   繁体   English

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

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

I'm trying to create a slack notification channel in GCP with terraform. I am able to create a channel with the code below, but it's missing "Team" and "Owner" attributes.我正在尝试使用 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>"
  }
}

The first channel in the screenshot below was created via GUI and works fine.下面屏幕截图中的第一个通道是通过 GUI 创建的,并且工作正常。 The second channel was created via terraform and is unable to send notificaitons:第二个通道是通过 terraform 创建的,无法发送通知:松弛通道

Terraform registry does not mention these attributes, I have tried defining them in labels right after channel_name : Terraform 注册表没有提到这些属性,我尝试在channel_name之后的标签中定义它们:

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

I got the following error:我收到以下错误:

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"}

Apparently, only channel_name and auth_token are valid labels.显然,只有channel_nameauth_token是有效标签。

What am I missing?我错过了什么?

Slack needs the sensitive_lables option for tokens. Slack 需要令牌的sensitive_lables选项。 There is an example in the docs 文档中有一个示例

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.

相关问题 Google Cloud 日志:如何将错误日志详细信息发送到另一个通道,例如 slack、email 或 webhook API? - Google Cloud logs: How to send error logs details to another channel like slack, email, or webhook API? 如何使用动态 IP 在谷歌云平台创建记录集? - How to create a record set in google cloud platform with dynamic IP? 如何在谷歌云平台(GCP)中创建组织下的文件夹? - How to create folders under the organization in Google Cloud Platform (GCP)? 如何编写 Terraform 模块在同一个谷歌云存储桶中创建多个文件夹? - How to write Terraform module to create multiple folders in same google cloud storage bucket? 谷歌云平台中的身份验证 - Authentication in Google Cloud Platform 如何禁用谷歌云平台集成? - How to disable Google Cloud Platform integration? 如何在 Google Cloud Platform CLI 中的配置之间切换 - Cloud Shell - How to Switch between Configurations in Google Cloud Platform CLI - Cloud Shell 如何在Google Cloud Platform中安装Google AI Platform中的Spark依赖 - How to install Spark dependencies in Google AI Platform in Google Cloud Platform 谷歌云平台 HTTPS - Google Cloud Platform HTTPS 在Google Cloud SQL Postgres上使用Terraform创建一个Replication Slot - Use Terraform on Google Cloud SQL Postgres to create a Replication Slot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM