terraform-provider-pagerduty: unable to use terraform-provider-pagerduty to create a Slack extension

$ terraform -v Terraform v0.10.8

aws_provider_version = “1.9” pagerduty_provider_version = “1.0”

Using the brand new pagerduty provider extension (thanks much for that!) https://github.com/terraform-providers/terraform-provider-pagerduty/pull/69

data "pagerduty_extension_schema" "webhook" {
  name = "Slack"
}

resource "pagerduty_extension" "slack" {
  name = "name"
  endpoint_url = "https://hooks.slack.com/services/redacted"
  extension_schema = "${data.pagerduty_extension_schema.webhook.id}"
  extension_objects    = ["${pagerduty_service.service.id}"]
}

If I use the “Slack” pagerduty_extension_schema, Terraform creates a new extension. However the extension doesn’t work (send messages to the appropriate slack channel) unless I authorize it in the Pagerduty console , and the icon in Pagerduty under Configuration / Extensions is broken (circle w/ a slash through it). If I then edit the new extension in Pagerduty, select the Slack channel, and authorize the extension, it will then work.

Questions -

  1. how do I fully automate creating an extension? I don’t see a way to authorize the extension and tell Pagerduty which slack channel to use for the notification using new extension
  2. is there a way to use “Generic V2 Webhook” as a Slack extension? I’m just looking for a way to make this work easily, I don’t need to use Generic V2 Webhook if the Slack extension will work.

“Generic V2 Webhook” pagerduty_extension_schema will create a new extension, but the extension won’t work.

Also, I notice that we have older Slack extensions in Pagerduty with a “Slack (legacy webhook)” type “Slack (Legacy Webhook)” pagerduty_extension_schema errors out with the following: “data.pagerduty_extension_schema.webhook: Unable to locate any extension schema with the name: Slack (Legacy Webhook)”

thanks, Dusty

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 21
  • Comments: 15 (5 by maintainers)

Most upvoted comments

What’s the update on this issue?

For future readers, this problem still exists because Slack has revoked the ability to create Legacy access tokens. We’re still waiting on a better solution from the PagerDuty Team.

Got a reply. As workaround it is possible to use existing oauth authorization using custom json in the config object. It is discussed in the https://community.pagerduty.com/t/how-to-pass-config-data-when-creating-an-extension/1857.

For me it looks like a good option, at least i see this token using API call:

$ curl --silent https://api.pagerduty.com/extensions/AB1234 \
    -H "Authorization: Token token=$PD_TOKEN" \
     | jq .extension.config.access_token
"XXXXX-XXXXXX-XXXXX-XXXXX-XXXX"

@cdhunt is there any chance to get https://github.com/terraform-providers/terraform-provider-pagerduty/pull/84 accepted? Looks like it could be a good workaround for that issue.

Alas, the access_token no longer appears in the config section, which now looks more like this:

$ curl --silent https://api.pagerduty.com/extensions/PXXWL6I     -H "Authorization: Token token=$PAGER_DUTY_API_KEY"  | jq .extension.config
{
  "restrict": "any",
  "notify_types": {
    "resolve": true,
    "acknowledge": true,
    "assignments": true,
    "annotate": false
  },
  "ok": true,
  "scope": "identify,bot,incoming-webhook,channels:read,groups:read,im:read,users:read,users:read.email,chat:write:bot,groups:write",
  "user_id": "UXXXXM12L",
  "team_name": "GxSx",
  "team_id": "T7D4XXXX",
  "incoming_webhook": {
    "channel": "#woollyams-test-alerts",
    "channel_id": "CF2ABXXXX",
    "configuration_url": "https://greensync-corp.slack.com/services/BF24UXXXX",
    "url": "https://hooks.slack.com/services/T7D4XXXX/BF24UXXXX/xxxxA6itEIPjBpzQhscqWXUW"
  },
  "bot": {
    "bot_user_id": "U7M3EXXXX"
  }
}

I haven’t been able to find a way to “borrow” an existing extension to create a new one.

The API docs says:

Some Extension Schemas that require OAuth Authorization to be setup, such as the Slack and HipChat extension, cannot be configured through the API.