Jira Cloud Integration using Terraform

Hey,

May I ask if the pagerduty terraform provider supports the Jira cloud integration? Our team is using terraform to manage our apps. So if it does, how should we implement it?

Thanks,
Sisi

We’d recommend setting up an example Jira Cloud extension on a service, then making a GET call using cURL or any other tool to our /extensions endpoint, inspecting the payload and replacing all relevant Jira and PagerDuty fields in this sample payload:

resource "pagerduty_user" "example" {
  name  = "Earline Greenholt"
  email = "125.greenholt.earline@graham.name"
}
resource "pagerduty_escalation_policy" "foos" {
  name      = "Foo Escalation Policy"
  num_loops = 2
  rule {
    escalation_delay_in_minutes = 10
    target {
      type = "user"
      id   = pagerduty_user.example.id
    }
  }
}
resource "pagerduty_service" "jira_connect" {
  name                    = "Connect my Jira"
  escalation_policy       = pagerduty_escalation_policy.foos.id
}
data "pagerduty_extension_schema" "jira_webhook" {
  name = "Jira Cloud"
}
resource "pagerduty_extension" "jira_cloud" {
  name = "Test Jira Cloud"
  endpoint_url = ""
  extension_schema = data.pagerduty_extension_schema.jira_webhook.id
  extension_objects    = [pagerduty_service.jira_connect.id]
  config = <<EOF
{
    "jira": {
        "acknowledgedStatus": {
            "id": "3",
            "name": "In Progress",
            "statusCategory": {
                "id": 4,
                "key": "indeterminate",
                "name": "In Progress"
                    },
                "untranslatedName": "Work in progress"
                },
                "autocreateJQL": "status=\"To Do\"",
                "createIssueOnIncidentTrigger": true,
                "customFields": [
                    {
                        "jira": {
                            "displayName": "Summary",
                            "isValid": true,
                            "type": "attribute",
                            "value": "summary"
                        },
                        "pd": {
                            "displayName": "Incident Title",
                            "isValid": true,
                            "type": "attribute",
                            "value": "incident.title"
                        }
                    }
                ],
                "issueType": {
                    "id": "10005",
                    "name": "Bug",
                    "subtask": false
                },
                "openStatus": {
                    "id": "10000",
                    "name": "To Do",
                    "statusCategory": {
                        "id": 2,
                        "key": "new",
                        "name": "To Do"
                    },
                    "untranslatedName": "To Do"
                },
                "priorities": [
                    {
                        "jiraId": "1",
                        "pdId": "PXXXXX"
                    },
                    {
                        "jiraId": "2",
                        "pdId": "PXXXXX"
                    },
                    {
                        "jiraId": "3",
                        "pdId": "PXXXXX"
                    },
                    {
                        "jiraId": "4",
                        "pdId": "PXXXXX"
                    },
                    {
                        "jiraId": "5",
                        "pdId": "PXXXXX"
                    }
                ],
                "project": {
                    "id": "10000",
                    "key": "KT",
                    "name": "kat-test",
                    "projectTypeKey": "software"
                },
                "resolvedStatus": {
                    "id": "10002",
                    "name": "Done",
                    "statusCategory": {
                        "id": 3,
                        "key": "done",
                        "name": "Done"
                    },
                    "untranslatedName": "Done"
                },
                "user": null
            }
        }
EOF

Here’s a snippet of the cURL request you’d need to make to get the Jira Cloud extension info:

curl --location --request GET 'https://api.pagerduty.com/extensions?query=CONFIGURATION NAME OF JIRA CLOUD HERE' \
--header 'Authorization: Token token=API KEY HERE' \
--header 'Accept: application/vnd.pagerduty+json;version=2' \
--header 'Content-Type: application/json'

You’d need to add your Jira Cloud configuration name where prompted in that cURL which you can find in Integrations > Jira Cloud in PagerDuty.

If you have any further issues with this, we’d recommend reaching out at support@pagerduty.com so we can dive into this in more depth with you.

2 Likes