terraform-provider-pagerduty icon indicating copy to clipboard operation
terraform-provider-pagerduty copied to clipboard

pagerduty_incident_workflow is not applying cleanly for pagerduty.com:slack:send-markdown-message:2

Open aelmekeev opened this issue 9 months ago • 0 comments

Hi there,

pagerduty_incident_workflow when it comes to using pagerduty.com:slack:send-markdown-message:2 to send slack notification to the channel requires Channel ID to be specified - otherwise the notification won't be sent to Slack. At the same time if we specify it in the resource it would always show up in the subsequents plans after apply.

Terraform Version

Terraform v1.8.3
on darwin_amd64
+ provider registry.terraform.io/pagerduty/pagerduty v3.12.1

Note:

Affected Resource(s)

  • pagerduty_incident_workflow

Terraform Configuration Files

locals {
  slack_message_inputs = [{
    name  = "Workspace"
    value = "<TODO>"
    }, {
    name  = "Channel"
    value = "A specific channel"
    }, {
    name  = "Select the Channel"
    value = "<TODO>"
  }]
}

resource "pagerduty_incident_workflow" "channel_id_test" {
  name        = "Channel ID test"
  description = "Test if slack message will be sent if channel id is not specified in incident workflow"

  step {
    name   = "Call #testtest channel with channel ID"
    action = "pagerduty.com:slack:send-markdown-message:2"


    dynamic "input" {
      for_each = local.slack_message_inputs
      content {
        name  = input.value.name
        value = input.value.value
      }
    }

    input {
      name  = "Channel ID"
      value = "<TODO>"
    }

    input {
      name  = "Message"
      value = "Call #testtest channel with channel ID"
    }
  }

  step {
    name   = "Call #testtest channel without channel ID"
    action = "pagerduty.com:slack:send-markdown-message:2"


    dynamic "input" {
      for_each = local.slack_message_inputs
      content {
        name  = input.value.name
        value = input.value.value
      }
    }

    input {
      name  = "Message"
      value = "Call #testtest channel without channel ID"
    }
  }
}

resource "pagerduty_incident_workflow_trigger" "this" {
  type                       = "manual"
  workflow                   = pagerduty_incident_workflow.channel_id_test.id
  subscribed_to_all_services = true
}

Debug Output

Don't want to sanitise the whole output but here are relevant bits of the debug log.

Panic Output

N/A

Expected Behavior

Ideally, I would prefer not to specify the channel id (see also https://github.com/PagerDuty/terraform-provider-pagerduty/issues/431) but if we have to specify it plan should be clean after successful apply.

Actual Behavior

IN the plan we see something like:

  # pagerduty_incident_workflow.channel_id_test will be updated in-place
  ~ resource "pagerduty_incident_workflow" "channel_id_test" {
        id          = "<id>"
        name        = "Channel ID test"
        # (1 unchanged attribute hidden)

      ~ step {
            id     = "<id>"
            name   = "Call #testtest channel with channel ID"
            # (1 unchanged attribute hidden)

          + input {
              + generated = false
              + name      = "Channel ID"
              + value     = "<id>"
            }

            # (5 unchanged blocks hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

And if we don't specify channel id we would not get the message in slack: image

Steps to Reproduce

  1. terraform apply
  2. terraform plan

Important Factoids

Reproducible on clean setup.

References

N/A

aelmekeev avatar May 20 '24 15:05 aelmekeev