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

Viewed 1049

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.

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. The second channel was created via terraform and is unable to send notificaitons: Slack channels

Terraform registry does not mention these attributes, I have tried defining them in labels right after 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.

What am I missing?

0 Answers
Related