我正在尝试使用Terraform在GCP中创建Slack通知频道。 我能够使用以下代码创建一个频道,但是它缺少“团队”和“所有者”属性。
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 创建的,无法发送通知:
![Slack channels](https://i.imgur.com/1yUV9Ry.png)
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_name 和 auth_token 是有效的标签。
我错过了什么吗?
team
和owner
字段应该对于google_monitoring_notification_channel
资源类型有效。 - Bernard Halasowner
和team
的值不在Google API中,因此在这种情况下最好的渠道是直接在terraform中开启一个案例。 - Marlen Monroy