PagerDuty / terraform-provider-pagerduty

Terraform PagerDuty provider
https://www.terraform.io/docs/providers/pagerduty/
Mozilla Public License 2.0
203 stars 212 forks source link

Add-one extension service with Slack2 to specific channel configuration. #448

Open JayChanggithub opened 2 years ago

JayChanggithub commented 2 years ago

Hi there,

Terraform Version

Terraform v0.15.3

Affected Resource(s)

Please list the resources as a list, for example:

i wanna to implement extension add-on to specific service. The extension add-on is Slack V2 and associate specific channel. I not very sure my configuration have any miss?

Terraform Configuration Files

resource "pagerduty_extension" "slack"{
  name = "#alert" # channel name
  endpoint_url = "https://hooks.slack.com/services/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" # this is slack channel link
  /* extension_schema = data.pagerduty_extension_schema.webhook.id */  # i don't know this argument that i need fill out what information.
  extension_objects    = [pagerduty_service.promethues.id] 
}

Panic Output

$ terraform plan                                                                                                                                                                                                   [12:13:53]
Acquiring state lock. This may take a few moments...
Releasing state lock. This may take a few moments...
╷
│ Warning: Version constraints inside provider configuration blocks are deprecated
│ 
│   on backend.tf line 12, in provider "azurerm":
│   12:   version = "~>2.0"
│ 
│ Terraform 0.13 and earlier allowed provider version constraints inside the provider configuration block, but that is now deprecated and will be removed in a future version of Terraform. To silence this warning, move the
│ provider version constraint into the required_providers block.
╵
╷
│ Error: Missing required argument
│ 
│   on extentionsvc.tf line 1, in resource "pagerduty_extension" "slack":
│    1: resource "pagerduty_extension" "slack"{
│ 
│ The argument "extension_schema" is required, but no definition was found.
╵
FAIL: 1
JayChanggithub commented 2 years ago
Screen Shot 2022-01-18 at 12 19 38 PM
bohdanborovskyi-ma commented 2 years ago

@JayChanggithub In case you want to send notifications from specific PD service into some Slack channels, brand new slack_connection resources might do the trick.

I've used this method and it does the job nicely, but have few drawbacks:

In case you need extension add-on specifically, here is the code example which might work according to docs:

data "pagerduty_extension_schema" "slack_v2" {
  name = "Slack V2"
}

resource "pagerduty_extension" "slack"{
  name = "channel name"
  endpoint_url = "slack hook url"
  extension_schema = data.pagerduty_extension_schema.slack_v2.id
  extension_objects    = [pagerduty_service.promethues.id] 
}

However, multiple issues in that repo states that those Slack V2 extensions wouldn't work anymore due to changes on Slack API side and PD folks recommend using slack_connection instead (example).