Search code examples
terraformslacknewrelic

Terraform: New Relic Provider - Slack Notification Chann


Looking for a good example or list of inputs to provide for a Terraform script to create a New Relic Slack Alert Channel. The only example I have found was in the Terraform docs, but for email.

Taking a guess here, but Slack probably has different

# Add a notification channel
resource "newrelic_alert_channel" "email" {
  name = "email"
  type = "email"

  configuration = {
    recipients              = "[email protected]"
    include_json_attachment = "1"
  }
}

Solution

  • resource newrelic_alert_channel does support type of slack.

    type - (Required) The type of channel. One of: campfire, email, hipchat, opsgenie, pagerduty, slack, victorops, or webhook.

    Refer: https://github.com/terraform-providers/terraform-provider-newrelic/blob/c1b47912aae73dffc2dbab8b7082ae46942aa8f9/newrelic/resource_newrelic_alert_channel.go#L37-L40

    "slack": {
        "channel",
        "url",
    },
    

    I didn't test, but will this code work?

    resource "newrelic_alert_channel" "slack" {
      name = "alerts"
      type = "slack"
    
      configuration = {
        channel = "alerts"
        url     = "https://hooks.slack.com/services/***********"
      }
    }