[英]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_name和auth_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.