Coo*_*ter 7 google-cloud-platform terraform slack stackdriver
我希望从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 + type产生以下输出:
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
Run Code Online (Sandbox Code Playgroud)
因此,我认为通知渠道的Terraform配置希望是:
resource "google_monitoring_notification_channel" "basic" {
display_name = "My slack notifications"
type = "slack"
labels = {
auth_token = "????????"
channel_name = "#notification-channel"
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何获取此脚本的身份验证令牌?我似乎无法从Slack 或 gcloud中提取已经设置的代码,也找不到从头开始创建代码的任何说明...
注意:这不是特定于Terraform的问题,因为脚本只是与Google REST API挂钩。因此,任何直接使用API的人也必须从某个地方获取此auth_token。必须有一种预期的方式来获取它,或者为什么在API中根本没有它...?
Mat*_*man 12
&auth_token=
查询字符串中的参数复制/粘贴身份验证令牌您最终将获得一个额外的通知渠道,即您在控制台中创建的那个,但之后您将能够在 terraform 管理的通知渠道中重用身份验证令牌。
归档时间: |
|
查看次数: |
349 次 |
最近记录: |