【发布时间】:2019-07-19 22:56:04
【问题描述】:
我希望从 gcloud -> slack 设置一些警报,到目前为止,按照以下说明进行了测试:
但是,理想情况下,我会将这些通知的配置存储在 terraform 脚本中,这样如果需要重新设置,我就无需手动执行步骤。看起来这应该是可能的:https://www.terraform.io/docs/providers/google/r/monitoring_notification_channel.html
我运行了gcloud alpha monitoring channel-descriptors describe projects/<My Project>/notificationChannelDescriptors/slack,它为标签+类型生成以下输出:
labels:
- description: A permanent authentication token provided by Slack. This field is obfuscated
by returning only a few characters of the key when fetched.
key: auth_token
- description: The Slack channel to which to post notifications.
key: channel_name
type: slack
所以,我认为通知通道的 terraform 配置应该是:
resource "google_monitoring_notification_channel" "basic" {
display_name = "My slack notifications"
type = "slack"
labels = {
auth_token = "????????"
channel_name = "#notification-channel"
}
}
但是,我不知道如何获取此脚本的身份验证令牌?我似乎无法从 Slack 或 gcloud 中提取我已经设置的那个,也找不到任何从头开始创建的说明...
注意这不是特定于 Terraform 的问题,因为脚本只是挂接到 google REST API。因此,任何直接使用 API 的人也必须从某个地方获取此 auth_token。必须有一种预期的方式来获取它,或者为什么它在 API 中......?
【问题讨论】:
标签: google-cloud-platform terraform slack stackdriver