=============== LIBRARY RULES =============== From library maintainers: - Use the PagerDuty Terraform provider to create, update, and delete users in your PagerDuty account as code. - Define and manage on-call schedules in PagerDuty using Terraform, ensuring consistent and version-controlled rotation policies. - Use Terraform to create and maintain PagerDuty escalation policies, automating incident response workflows across your teams. - Use pagerduty_service to define incident-managed services - Use pagerduty_schedule to automate on-call rotations - Use pagerduty_escalation_policy to codify escalation workflows - Use pagerduty_user to provision PagerDuty users - Use pagerduty_team to manage response teams - Use pagerduty_team_membership to assign users to teams - Use pagerduty_service_integration to connect monitoring tools - Use pagerduty_event_orchestration along with pagerduty_event_orchestration_router to automate event routing - Use pagerduty_extension to add Slack or webhook notifications - Use pagerduty_business_service to model business-impacting services ### Example Usage of Business Service Subscriber Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/business_service_subscriber.html.markdown This example demonstrates how to create a business service and then subscribe both a team and a user to it. Ensure the referenced business service, team, and user resources are defined. ```hcl resource "pagerduty_business_service" "example" { name = "My Web App" description = "A very descriptive description of this business service" point_of_contact = "PagerDuty Admin" team = "P37RSRS" } resource "pagerduty_team" "engteam" { name = "Engineering" } resource "pagerduty_user" "example" { name = "Earline Greenholt" email = "125.greenholt.earline@graham.name" } resource "pagerduty_business_service_subscriber" "team_example" { subscriber_id = pagerduty_team.engteam.id subscriber_type = "team" business_service_id = pagerduty_business_service.example.id } resource "pagerduty_business_service_subscriber" "user_example" { subscriber_id = pagerduty_user.example.id subscriber_type = "user" business_service_id = pagerduty_business_service.example.id } ``` -------------------------------- ### PagerDuty Response Play Example Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/response_play.html.markdown This example shows how to configure a pagerduty_response_play resource. It includes defining responders, subscribers, and the runnability of the play. Ensure pagerduty_user and pagerduty_escalation_policy resources are defined prior to this. ```hcl resource "pagerduty_user" "example" { name = "Earline Greenholt" email = "125.greenholt.earline@graham.name" teams = [pagerduty_team.example.id] } resource "pagerduty_escalation_policy" "example" { name = "Engineering Escalation Policy" num_loops = 2 rule { escalation_delay_in_minutes = 10 target { type = "user" id = pagerduty_user.example.id } } } resource "pagerduty_response_play" "example" { name = "My Response Play" from = pagerduty_user.example.email responder { type = "escalation_policy_reference" id = pagerduty_escalation_policy.example.id } subscriber { type = "user_reference" id = pagerduty_user.example.id } runnability = "services" } ``` -------------------------------- ### Configure Unrouted Rules for an Orchestration Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/event_orchestration_unrouted.html.markdown This example demonstrates how to configure an unrouted orchestration with a 'start' rule set and a catch-all action. The rule updates the summary of critical unrouted alerts and sets the severity to 'info' for any events that do not match the defined rule. ```hcl resource "pagerduty_event_orchestration_unrouted" "unrouted" { event_orchestration = pagerduty_event_orchestration.my_monitor.id set { id = "start" rule { label = "Update the summary of un-matched Critical alerts so they're easier to spot" condition { expression = "event.severity matches 'critical'" } actions { severity = "critical" extraction { target = "event.summary" template = "[Critical Unrouted] {{event.summary}}" } } } } catch_all { actions { severity = "info" } } } ``` -------------------------------- ### PagerDuty Service Resource Example Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/service.html.markdown Example of how to configure a PagerDuty service with incident urgency rules, support hours, and scheduled actions. ```APIDOC ## pagerduty_service Resource ### Description Configures a PagerDuty service with incident urgency rules, support hours, and scheduled actions. ### Arguments * `name` - (Required) The name of the service. * `description` - (Optional) A description of the service. * `auto_resolve_timeout` - (Optional) Indicates in seconds how long alerts should be suspended before triggering auto-resolve. Defaults to `14400`. * `acknowledgement_timeout` - (Optional) Indicates in seconds how long responders have to acknowledge an alert before it escalates. Defaults to `600`. * `escalation_policy` - (Required) The ID of the escalation policy to use for this service. #### `incident_urgency_rule` Block Configures rules for incident urgency. * `type` - (Required) The type of incident urgency: `constant` or `use_support_hours`. * `during_support_hours` - (Optional) Configuration for incidents during support hours. * `type` - (Required) The type of incident urgency: `constant` or `use_support_hours`. * `urgency` - (Required) The urgency level: `low`, `high`, or `severity_based`. * `outside_support_hours` - (Optional) Configuration for incidents outside support hours. * `type` - (Required) The type of incident urgency: `constant` or `use_support_hours`. * `urgency` - (Required) The urgency level: `low`, `high`, or `severity_based`. #### `support_hours` Block Configures support hours for the service. * `type` - (Required) The type of support hours. Currently, only `fixed_time_per_day` is supported. * `time_zone` - (Required) The time zone for the support hours (e.g., `America/Lima`). * `start_time` - (Required) The support hours' starting time of day (e.g., `09:00:00`). * `end_time` - (Required) The support hours' ending time of day (e.g., `17:00:00`). * `days_of_week` - (Required) Array of days of the week as integers (1-7, 1=Monday, 7=Sunday). #### `scheduled_actions` Block Configures scheduled actions for the service. * `type` - (Required) The type of scheduled action. Currently, only `urgency_change` is supported. * `to_urgency` - (Required) The urgency to change to: `low` or `high`. ##### `at` Block Specifies when the scheduled action will occur. * `type` - (Required) The type of time specification. Currently, only `named_time` is supported. * `name` - (Required) Designates the time: `support_hours_start` or `support_hours_end`. ### Example ```hcl resource "pagerduty_service" "foo" { name = "bar" description = "bar bar bar" auto_resolve_timeout = 3600 acknowledgement_timeout = 3600 escalation_policy = pagerduty_escalation_policy.foo.id incident_urgency_rule { type = "use_support_hours" during_support_hours { type = "constant" urgency = "high" } outside_support_hours { type = "constant" urgency = "low" } } support_hours { type = "fixed_time_per_day" time_zone = "America/Lima" start_time = "09:00:00" end_time = "17:00:00" days_of_week = [1, 2, 3, 4, 5] } scheduled_actions { type = "urgency_change" to_urgency = "high" at { type = "named_time" name = "support_hours_start" } } } ``` ``` -------------------------------- ### Get all users Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/users.html.markdown This example shows how to retrieve a list of all users in your PagerDuty account using the `pagerduty_users` data source. ```APIDOC ## Get all users ### Description Retrieves a list of all users in the PagerDuty account. ### Method GET ### Endpoint /users ### Parameters #### Query Parameters - `team_ids` (array) - Optional. List of team IDs to filter users by. ### Response #### Success Response (200) - `id` (string) - The ID of the queried list of users. - `users` (array) - List of users queried. Each user object contains: - `id` (string) - The ID of the found user. - `name` (string) - The short name of the found user. - `email` (string) - The email of the found user. - `role` (string) - The role of the found user. - `job_title` (string) - The job title of the found user. - `time_zone` (string) - The timezone of the found user. - `description` (string) - The human-friendly description of the found user. ### Response Example ```json { "id": "some_list_id", "users": [ { "id": "user_id_1", "name": "User One", "email": "user1@example.com", "role": "user", "job_title": "Developer", "time_zone": "UTC", "description": "First user in the account" }, { "id": "user_id_2", "name": "User Two", "email": "user2@example.com", "role": "admin", "job_title": "Manager", "time_zone": "America/New_York", "description": "Second user in the account" } ] } ``` ``` -------------------------------- ### Example Usage of Event Orchestrations Data Source Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/event_orchestrations.html.markdown This example demonstrates how to use the `pagerduty_event_orchestrations` data source to find Global Event Orchestrations matching a regex. It then uses the ID of the first found orchestration to configure a global cache variable. ```hcl resource "pagerduty_event_orchestration" "tf_orch_a" { name = "Test Event A Orchestration" } resource "pagerduty_event_orchestration" "tf_orch_b" { name = "Test Event B Orchestration" } data "pagerduty_event_orchestrations" "tf_my_monitor" { name_filter = ".*Orchestration$" } resource "pagerduty_event_orchestration_global_cache_variable" "cache_var" { event_orchestration = data.pagerduty_event_orchestrations.tf_my_monitor.event_orchestrations[0].id name = "recent_host" condition { expression = "event.source exists" } configuration { type = "recent_value" source = "event.source" regex = ".*" } } ``` -------------------------------- ### Example Usage of pagerduty_tag Data Source Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/tag.html.markdown This example demonstrates how to use the `pagerduty_tag` data source to retrieve a tag by its label and then assign it to a user using the `pagerduty_tag_assignment` resource. ```hcl data "pagerduty_user" "me" { email = "me@example.com" } data "pagerduty_tag" "devops" { label = "devops" } resource "pagerduty_tag_assignment" "foo" { tag_id = data.pagerduty_tag.devops.id entity_id = data.pagerduty_user.me.id entity_type = "users" } ``` -------------------------------- ### PagerDuty Event Orchestration Data Source Example Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/event_orchestration.html.markdown This example demonstrates how to use the `pagerduty_event_orchestration` data source to retrieve an existing Event Orchestration by name. It then uses the retrieved orchestration's ID and integration details to configure an `pagerduty_event_orchestration_unrouted` resource. ```hcl resource "pagerduty_event_orchestration" "tf_orch_a" { name = "Test Event Orchestration" } data "pagerduty_event_orchestration" "tf_my_monitor" { name = pagerduty_event_orchestration.tf_orch_a.name } resource "pagerduty_event_orchestration_unrouted" "unrouted" { event_orchestration = data.pagerduty_event_orchestration.tf_my_monitor.id catch_all { actions { severity = "info" } } set { id = "start" rule { actions { extraction { target = "event.custom_details.integration_type" template = data.pagerduty_event_orchestration.tf_my_monitor.integration[0].parameters[0].type } } } } } ``` -------------------------------- ### Example Usage of pagerduty_event_orchestration_global_cache_variable Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/event_orchestration_global_cache_variable.html.markdown This example demonstrates how to use the `pagerduty_event_orchestration_global_cache_variable` data source to retrieve details about a cache variable. It requires the ID of the event orchestration and the name of the cache variable. ```hcl resource "pagerduty_event_orchestration" "event_orchestration" { name = "Test Event Orchestration" } data "pagerduty_event_orchestration_global_cache_variable" "cache_variable" { event_orchestration = pagerduty_event_orchestration.event_orchestration.id name = "example_cache_variable" } ``` -------------------------------- ### PagerDuty Provider SECURE Log Output Example Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/index.html.markdown This example shows how API keys are obfuscated in the Authorization header when using the SECURE log level. It reveals only the last four characters of the key. ```sh ---[ REQUEST ]--------------------------------------- GET /teams/DER8RFS HTTP/1.1 Accept: application/vnd.pagerduty+json;version=2 Authorization: kCjQ Content-Type: application/json User-Agent: (darwin arm64) Terraform/1.5.1 ``` -------------------------------- ### PagerDuty User Notification Rule Example Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/user_notification_rule.html.markdown This example demonstrates how to create user notification rules for high and low urgency incidents, associating them with different contact methods. ```hcl resource "pagerduty_user" "example" { name = "Earline Greenholt" email = "125.greenholt.earline@graham.name" } resource "pagerduty_user_contact_method" "email" { user_id = pagerduty_user.example.id type = "email_contact_method" address = "foo@bar.com" label = "Work" } resource "pagerduty_user_contact_method" "phone" { user_id = pagerduty_user.example.id type = "phone_contact_method" country_code = "+1" address = "2025550199" label = "Work" } resource "pagerduty_user_contact_method" "sms" { user_id = pagerduty_user.example.id type = "sms_contact_method" country_code = "+1" address = "2025550199" label = "Work" } resource "pagerduty_user_notification_rule" "high_urgency_phone" { user_id = pagerduty_user.example.id start_delay_in_minutes = 1 urgency = "high" contact_method { type = "phone_contact_method" id = pagerduty_user_contact_method.phone.id } } resource "pagerduty_user_notification_rule" "low_urgency_email" { user_id = pagerduty_user.example.id start_delay_in_minutes = 1 urgency = "low" contact_method { type = "email_contact_method" id = pagerduty_user_contact_method.email.id } } resource "pagerduty_user_notification_rule" "low_urgency_sms" { user_id = pagerduty_user.example.id start_delay_in_minutes = 10 urgency = "low" contact_method { type = "sms_contact_method" id = pagerduty_user_contact_method.sms.id } } ``` -------------------------------- ### Example of Secure Log Output Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/README.md When the `SECURE` log level is enabled, API keys in the Authorization header are obfuscated, showing only the last four characters, as demonstrated in this example request log. ```sh --- ---[ REQUEST ]--------------------------------------- GET /teams/DER8RFS HTTP/1.1 Accept: application/vnd.pagerduty+json;version=2 Authorization: kCjQ Content-Type: application/json User-Agent: (darwin arm64) Terraform/1.5.1 ``` -------------------------------- ### Create a PagerDuty Business Service Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/business_service.html.markdown Example of how to create a business service with required and optional arguments. ```hcl resource "pagerduty_business_service" "example" { name = "My Web App" description = "A very descriptive description of this business service" point_of_contact = "PagerDuty Admin" team = "P37RSRS" } ``` -------------------------------- ### Import a PagerDuty Ruleset Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/ruleset.html.markdown This example demonstrates how to import an existing PagerDuty ruleset using its ID. The ID is typically a UUID. ```bash terraform import pagerduty_ruleset.main 19acac92-027a-4ea0-b06c-bbf516519601 ``` -------------------------------- ### Import a PagerDuty Extension Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/extension.html.markdown This example shows how to import an existing PagerDuty extension into your Terraform state using its ID. ```bash $ terraform import pagerduty_extension.main PLBP09X ``` -------------------------------- ### Get users filtered by team IDs Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/users.html.markdown This example demonstrates how to retrieve a list of users associated with specific teams using the `team_ids` argument. ```APIDOC ## Get users filtered by team IDs ### Description Retrieves a list of users that belong to the specified team IDs. ### Method GET ### Endpoint /users?team_ids={team_id1},{team_id2} ### Parameters #### Query Parameters - `team_ids` (array) - Required. List of team IDs. Only results related to these teams will be returned. Account must have the `teams` ability to use this parameter. ### Response #### Success Response (200) - `id` (string) - The ID of the queried list of users. - `users` (array) - List of users queried. Each user object contains: - `id` (string) - The ID of the found user. - `name` (string) - The short name of the found user. - `email` (string) - The email of the found user. - `role` (string) - The role of the found user. - `job_title` (string) - The job title of the found user. - `time_zone` (string) - The timezone of the found user. - `description` (string) - The human-friendly description of the found user. ### Response Example ```json { "id": "some_list_id_for_team", "users": [ { "id": "user_id_3", "name": "User Three", "email": "user3@example.com", "role": "user", "job_title": "Engineer", "time_zone": "UTC", "description": "User in specified team" } ] } ``` ``` -------------------------------- ### Configure Router Rules for Event Orchestration Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/event_orchestration_router.html.markdown This example demonstrates configuring a router with multiple rules, including dynamic routing based on custom event details and conditional routing to specific services. It also shows how to define a catch-all route. ```hcl data "pagerduty_service" "database" { name = "Primary Data Store" } data "pagerduty_service" "www" { name = "Web Server App" } resource "pagerduty_event_orchestration_router" "router" { event_orchestration = pagerduty_event_orchestration.my_monitor.id set { id = "start" rule { label = "Dynamically route events related to specific PagerDuty services" actions { dynamic_route_to { lookup_by = "service_id" source = "event.custom_details.pd_service_id" regex = "(.*)" } } } rule { label = "Events relating to our relational database" condition { expression = "event.summary matches part 'database'" } condition { expression = "event.source matches regex 'db[0-9]+-server'" } actions { route_to = data.pagerduty_service.database.id } } rule { condition { expression = "event.summary matches part 'www'" } actions { route_to = data.pagerduty_service.www.id } } } catch_all { actions { route_to = "unrouted" } } } ``` -------------------------------- ### Configure Global Event Orchestration Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/event_orchestration_global.html.markdown This example demonstrates creating a Global Orchestration with nested rule sets, including routing to other sets, dropping events, and applying various actions like setting priority, severity, and triggering automation. It also shows the use of data sources for priority and escalation policies. ```hcl resource "pagerduty_team" "database_team" { name = "Database Team" } resource "pagerduty_event_orchestration" "event_orchestration" { name = "Example Orchestration" team = pagerduty_team.database_team.id } data "pagerduty_priority" "p1" { name = "P1" } data "pagerduty_escalation_policy" "sre_esc_policy" { name = "SRE Escalation Policy" } resource "pagerduty_event_orchestration_global" "global" { event_orchestration = pagerduty_event_orchestration.event_orchestration.id set { id = "start" rule { label = "Always annotate a note to all events" actions { annotate = "This incident was created by the Database Team via a Global Orchestration" # Id of the next set route_to = "step-two" } } } set { id = "step-two" rule { label = "Drop events that are marked as no-op" condition { expression = "event.summary matches 'no-op'" } actions { drop_event = true } } rule { label = "If the DB host is running out of space, then page the SRE team" condition { expression = "event.summary matches part 'running out of space'" } actions { escalation_policy = data.pagerduty_escalation_policy.sre_esc_policy.id } } rule { label = "If there's something wrong on the replica, then mark the alert as a warning" condition { expression = "event.custom_details.hostname matches part 'replica'" } actions { severity = "warning" } } rule { label = "Otherwise, set the incident to P1, pause for 10 mins and run a diagnostic once the alert is suspended" actions { priority = data.pagerduty_priority.p1.id suspend = 600 automation_action { name = "db-diagnostic" url = "https://example.com/run-diagnostic" auto_send = true trigger_types = ["alert_suspended"] } } } } catch_all { actions { } } } ``` -------------------------------- ### Get Service Custom Field Value Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/service_custom_field_value.html.markdown This example demonstrates how to use the `pagerduty_service_custom_field_value` data source to fetch custom field values for a given service. It then shows how to extract a specific field's value, like 'environment'. ```APIDOC ## Data Source: pagerduty_service_custom_field_value ### Description Use this data source to get information about service custom field values in PagerDuty. ### Argument Reference The following arguments are supported: * `service_id` - (Required) The ID of the service to get custom field values for. ### Attributes Reference The following attributes are exported: * `id` - The ID of the service. * `custom_fields` - A list of custom field values associated with the service. Each element contains: * `id` - The ID of the custom field. * `name` - The name of the custom field. * `display_name` - The human-readable name of the custom field. * `description` - A description of the data this field contains. * `data_type` - The kind of data the custom field is allowed to contain. Can be one of: `string`, `integer`, `float`, `boolean`, `datetime`, or `url`. * `field_type` - The type of field. Can be one of: `single_value`, `single_value_fixed`, `multi_value`, or `multi_value_fixed`. * `type` - The type of the reference, typically "field_value". * `value` - The value of the custom field. This is a JSON-encoded string matching the field's data type. ### Example Usage ```hcl data "pagerduty_service_custom_field_value" "example" { service_id = pagerduty_service.example.id } output "environment_value" { value = [ for field in data.pagerduty_service_custom_field_value.example.custom_fields : field.value if field.name == "environment" ][0] } ``` ``` -------------------------------- ### Get Incident Workflow and Create a Trigger Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/incident_workflow.html.markdown Use the `pagerduty_incident_workflow` data source to fetch an incident workflow by name. Then, use its ID to create a conditional trigger with the `pagerduty_incident_workflow_trigger` resource. This example also shows how to fetch a service to associate with the trigger. ```hcl data "pagerduty_incident_workflow" "my_workflow" { name = "Some Workflow Name" } data "pagerduty_service" "first_service" { name = "My First Service" } resource "pagerduty_incident_workflow_trigger" "automatic_trigger" { type = "conditional" workflow = data.pagerduty_incident_workflow.my_workflow.id services = [data.pagerduty_service.first_service.id] condition = "incident.priority matches 'P1'" } ``` -------------------------------- ### Run Unit Tests Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/README.md Execute the provider's unit tests using the `make test` command. No special environment variables are required. ```sh $ make test ``` -------------------------------- ### Import Event Orchestration Integration Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/event_orchestration_integration.html.markdown Demonstrates how to import an existing Event Orchestration Integration using its ID and the associated Event Orchestration ID. ```bash $ terraform import pagerduty_event_orchestration_integration.integration 19acac92-027a-4ea0-b06c-bbf516519601:1b49abe7-26db-4439-a715-c6d883acfb3e ``` -------------------------------- ### Create a ServiceNow Service Extension Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/extension_servicenow.html.markdown This example demonstrates how to create a ServiceNow service extension. It requires a ServiceNow schema, a PagerDuty user, escalation policy, and service to be defined. Ensure all required arguments like `extension_schema`, `extension_objects`, `snow_user`, `snow_password`, `sync_options`, `target`, `task_type`, and `referer` are provided. ```hcl data "pagerduty_extension_schema" "servicenow" { name = "ServiceNow (v7)" } resource "pagerduty_user" "example" { name = "Howard James" email = "howard.james@example.domain" } resource "pagerduty_escalation_policy" "example" { name = "Engineering Escalation Policy" num_loops = 2 rule { escalation_delay_in_minutes = 10 target { type = "user" id = pagerduty_user.example.id } } } resource "pagerduty_service" "example" { name = "My Web App" auto_resolve_timeout = 14400 acknowledgement_timeout = 600 escalation_policy = pagerduty_escalation_policy.example.id } resource "pagerduty_extension_servicenow" "snow" { name = "My Web App Extension" extension_schema = data.pagerduty_extension_schema.servicenow.id extension_objects = [pagerduty_service.example.id] snow_user = "meeps" snow_password = "zorz" sync_options = "manual_sync" target = "https://foo.servicenow.com/webhook_foo" task_type = "incident" referer = "None" } ``` -------------------------------- ### Configure an Event Orchestration Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/event_orchestration.html.markdown This example shows how to create a basic Event Orchestration associated with a team. Ensure the `pagerduty_team` resource is defined or imported first. ```hcl resource "pagerduty_team" "engineering" { name = "Engineering" } resource "pagerduty_event_orchestration" "my_monitor" { name = "My Monitoring Orchestration" description = "Send events to a pair of services" team = pagerduty_team.engineering.id } ``` -------------------------------- ### Initialize and Plan Terraform with Local Provider Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/README.md After configuring local overrides, run `terraform init -upgrade` and `terraform plan` in your module directory. A warning message will indicate that development overrides are active. ```bash $ terraform init -upgrade $ terraform plan ... │ Warning: Provider development overrides are in effect ``` -------------------------------- ### Create User Contact Methods Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/user_contact_method.html.markdown Example of creating email, phone, and SMS contact methods for a user. Ensure the `pagerduty_user` resource is defined. ```hcl resource "pagerduty_user" "example" { name = "Earline Greenholt" email = "125.greenholt.earline@graham.name" teams = [pagerduty_team.example.id] } resource "pagerduty_user_contact_method" "email" { user_id = pagerduty_user.example.id type = "email_contact_method" address = "foo@bar.com" label = "Work" } resource "pagerduty_user_contact_method" "phone" { user_id = pagerduty_user.example.id type = "phone_contact_method" country_code = "+1" address = "2025550199" label = "Work" } resource "pagerduty_user_contact_method" "sms" { user_id = pagerduty_user.example.id type = "sms_contact_method" country_code = "+1" address = "2025550199" label = "Work" } ``` -------------------------------- ### Get PagerDuty Service Integration Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/service_integration.html.markdown Use this data source to get information about a specific service integration. It requires the service name and integration summary to find the desired integration. ```hcl data "pagerduty_service_integration" "example" { service_name = "My Service" integration_summary = "Datadog" } ``` -------------------------------- ### Create a PagerDuty Service Integration with a Vendor Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/d/vendor.html.markdown This example demonstrates how to create a service integration using a vendor identified by the `pagerduty_vendor` data source. It requires an existing service and escalation policy. ```hcl resource "pagerduty_user" "example" { name = "Earline Greenholt" email = "125.greenholt.earline@graham.name" teams = [pagerduty_team.example.id] } resource "pagerduty_escalation_policy" "foo" { name = "Engineering Escalation Policy" num_loops = 2 rule { escalation_delay_in_minutes = 10 target { type = "user" id = pagerduty_user.example.id } } } resource "pagerduty_service" "example" { name = "My Web App" auto_resolve_timeout = 14400 acknowledgement_timeout = 600 escalation_policy = pagerduty_escalation_policy.example.id } resource "pagerduty_service_integration" "example" { name = "Datadog Integration" vendor = data.pagerduty_vendor.datadog.id service = pagerduty_service.example.id } ``` -------------------------------- ### Import a PagerDuty Business Service Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/business_service.html.markdown Demonstrates how to import an existing business service into Terraform management. ```bash $ terraform import pagerduty_business_service.main PLBP09X ``` -------------------------------- ### Create Jira Cloud Account Mapping Rule Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/jira_cloud_account_mapping_rule.html.markdown This example demonstrates how to create a Jira Cloud account mapping rule, configuring service integration, Jira project details, issue type, priority mapping, status mapping, and user synchronization for notes. ```hcl data "pagerduty_escalation_policy" "default" { name = "Default" } data "pagerduty_priority" "p1" { name = "P1" } data "pagerduty_priority" "p2" { name = "P2" } data "pagerduty_priority" "p3" { name = "P3" } resource "pagerduty_service" "foo" { name = "My Web App" escalation_policy = data.pagerduty_escalation_policy.default.id } resource "pagerduty_user" "foo" { name = "Earline Greenholt" email = "125.greenholt.earline@graham.name" } resource "pagerduty_jira_cloud_account_mapping_rule" "foo" { name = "Integration with My Web App" account_mapping = "PLBP09X" config { service = pagerduty_service.foo.id jira { autocreate_jql = "priority = Highest" create_issue_on_incident_trigger = true custom_fields { source_incident_field = "incident_description" target_issue_field = "description" target_issue_field_name = "Description" type = "attribute" } custom_fields { target_issue_field = "security" target_issue_field_name = "Security Level" type = "jira_value" value = jsonencode({ displayName = "Sec Level 1" id = "10000" }) } issue_type { id = "10001" name = "Incident" } priorities { jira_id = "1" pagerduty_id = data.pagerduty_priority.p1.id } priorities { jira_id = "2" pagerduty_id = data.pagerduty_priority.p2.id } priorities { jira_id = "3" pagerduty_id = data.pagerduty_priority.p3.id } project { id = "10100" key = "ITS" name = "IT Support" } status_mapping { acknowledged { id = "2" name = "In Progress" } resolved { id = "3" name = "Resolved" } triggered { id = "1" name = "Open" } } sync_notes_user = pagerduty_user.foo.id } } } ``` -------------------------------- ### Get Schedules Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/guides/pagerduty_api_support_status.html.markdown Retrieves a list of all schedules. ```APIDOC ## GET /schedules ### Description Retrieves a list of all schedules. ### Method GET ### Endpoint /schedules ``` -------------------------------- ### Import Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/event_orchestration_unrouted.html.markdown Instructions on how to import an existing unrouted event orchestration. ```APIDOC ## Import Unrouted Orchestration can be imported using the `id` of the Event Orchestration, e.g. ```terraform $ terraform import pagerduty_event_orchestration_unrouted.unrouted 1b49abe7-26db-4439-a715-c6d883acfb3e ``` ``` -------------------------------- ### Get Rulesets Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/guides/pagerduty_api_support_status.html.markdown Retrieves a list of all rulesets. ```APIDOC ## GET /rulesets ### Description Retrieves a list of all rulesets. ### Method GET ### Endpoint /rulesets ``` -------------------------------- ### Create a Service Integration with Vendor (Datadog) Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/service_integration.html.markdown Use this to create a service integration linked to a specific vendor, like Datadog. The service and vendor resources must be defined. ```hcl data "pagerduty_vendor" "datadog" { name = "Datadog" } resource "pagerduty_service_integration" "datadog" { name = data.pagerduty_vendor.datadog.name service = pagerduty_service.example.id vendor = data.pagerduty_vendor.datadog.id } ``` -------------------------------- ### Create Process Automation and Script Actions Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/automation_actions_action.html.markdown Example of creating both a Process Automation action and a script action. The Process Automation action requires a `process_automation_job_id`, while the script action requires the `script` body and optionally an `invocation_command`. ```hcl resource "pagerduty_automation_actions_action" "pa_action_example" { name = "PA Action created via TF" description = "Description of the PA Action created via TF" action_type = "process_automation" action_data_reference { process_automation_job_id = "P123456" } } resource "pagerduty_automation_actions_action" "script_action_example" { name = "Script Action created via TF" description = "Description of the Script Action created via TF" action_type = "script" action_data_reference { script = "print(\"Hello from a Python script!\")" invocation_command = "/usr/local/bin/python3" } } ``` -------------------------------- ### Configure Advanced Email Service Integration Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/service_integration.html.markdown This example demonstrates advanced configuration for an email integration, including email filtering rules and value extraction for incident parsing. Ensure the service and vendor resources are defined. ```hcl data "pagerduty_vendor" "email" { name = "Email" } resource "pagerduty_service_integration" "email" { name = data.pagerduty_vendor.email.name service = pagerduty_service.example.id vendor = data.pagerduty_vendor.email.id integration_email = "s1@your_account.pagerduty.com" email_incident_creation = "use_rules" email_filter_mode = "and-rules-email" email_filter { body_mode = "always" body_regex = null from_email_mode = "match" from_email_regex = "(@foo.test*)" subject_mode = "match" subject_regex = "(CRITICAL*)" } email_filter { body_mode = "always" body_regex = null from_email_mode = "match" from_email_regex = "(@bar.com*)" subject_mode = "match" subject_regex = "(CRITICAL*)" } email_parser { action = "resolve" match_predicate { type = "any" predicate { matcher = "foo" part = "subject" type = "contains" } predicate { type = "not" predicate { matcher = "(bar*)" part = "body" type = "regex" } } } value_extractor { ends_before = "end" part = "subject" starts_after = "start" type = "between" value_name = "incident_key" } value_extractor { ends_before = "end" part = "subject" starts_after = "start" type = "between" value_name = "FieldName1" } } } ``` -------------------------------- ### Get Schedule by ID Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/guides/pagerduty_api_support_status.html.markdown Retrieves a specific schedule by its ID. ```APIDOC ## GET /schedules/{id} ### Description Retrieves a specific schedule by its ID. ### Method GET ### Endpoint /schedules/{id} #### Path Parameters - **id** (string) - Required - The ID of the schedule to retrieve. ``` -------------------------------- ### Get Ruleset by ID Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/guides/pagerduty_api_support_status.html.markdown Retrieves a specific ruleset by its ID. ```APIDOC ## GET /rulesets/{id} ### Description Retrieves a specific ruleset by its ID. ### Method GET ### Endpoint /rulesets/{id} #### Path Parameters - **id** (string) - Required - The ID of the ruleset to retrieve. ``` -------------------------------- ### Configure Go Modules Preference Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/README.md Set the `GOFLAGS` environment variable to `-mod=mod` to ensure Go uses the `go.mod` file for module resolution, or run `go mod vendor` to update vendored dependencies. ```bash $ export GOFLAGS="-mod=mod" ``` ```bash $ go mod vendor ``` -------------------------------- ### Get Priorities Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/guides/pagerduty_api_support_status.html.markdown Retrieves a list of all available priorities in PagerDuty. ```APIDOC ## GET /priorities ### Description Retrieves a list of all available priorities in PagerDuty. ### Method GET ### Endpoint /priorities ``` -------------------------------- ### Get Specific User Session Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/guides/pagerduty_api_support_status.html.markdown Retrieves a specific session for a user. ```APIDOC ## GET /users/{id}/sessions/{type}/{session_id} ### Description Retrieves a specific session for a user. ### Method GET ### Endpoint /users/{id}/sessions/{type}/{session_id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the user. - **type** (string) - Required - The type of the session. - **session_id** (string) - Required - The unique identifier of the session. ``` -------------------------------- ### Configure PagerDuty Event Orchestration Service Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/r/event_orchestration_service.html.markdown This example configures a PagerDuty Event Orchestration Service, including setting up nested rule sets and defining actions for event routing and transformation. It requires a PagerDuty service to be pre-configured. ```hcl resource "pagerduty_team" "engineering" { name = "Engineering" } resource "pagerduty_user" "example" { name = "Earline Greenholt" email = "125.greenholt.earline@graham.name" } resource "pagerduty_team_membership" "foo" { user_id = pagerduty_user.example.id team_id = pagerduty_team.engineering.id role = "manager" } resource "pagerduty_escalation_policy" "example" { name = "Engineering Escalation Policy" num_loops = 2 rule { escalation_delay_in_minutes = 10 target { type = "user_reference" id = pagerduty_user.example.id } } } resource "pagerduty_service" "example" { name = "My Web App" auto_resolve_timeout = 14400 acknowledgement_timeout = 600 escalation_policy = pagerduty_escalation_policy.example.id alert_creation = "create_alerts_and_incidents" } resource "pagerduty_incident_custom_field" "cs_impact" { name = "impact" data_type = "string" field_type = "single_value" } data "pagerduty_priority" "p1" { name = "P1" } data "pagerduty_escalation_policy" "sre_esc_policy" { name = "SRE Escalation Policy" } resource "pagerduty_event_orchestration_service" "www" { service = pagerduty_service.example.id enable_event_orchestration_for_service = true set { id = "start" rule { label = "Always apply some consistent event transformations to all events" actions { variable { name = "hostname" path = "event.component" value = "hostname: (.*)" type = "regex" } extraction { # Demonstrating a template-style extraction template = "{{variables.hostname}}" target = "event.custom_details.hostname" } extraction { # Demonstrating a regex-style extraction source = "event.source" regex = "www (.*) service" target = "event.source" } # Id of the next set route_to = "step-two" } } } set { id = "step-two" rule { label = "All critical alerts should be treated as P1 incident" condition { expression = "event.severity matches 'critical'" } actions { annotate = "Please use our P1 runbook: https://docs.test/p1-runbook" priority = data.pagerduty_priority.p1.id incident_custom_field_update { id = pagerduty_incident_custom_field.cs_impact.id value = "High Impact" } } } rule { label = "If any of the API apps are unavailable, page the SRE team" condition { expression = "event.custom_details.service_name matches part '-api' and event.custom_details.status_code matches '502'" } actions { escalation_policy = data.pagerduty_escalation_policy.sre_esc_policy.id } } rule { label = "If there's something wrong on the canary let the team know about it in our deployments Slack channel" condition { expression = "event.custom_details.hostname matches part 'canary'" } # create webhook action with parameters and headers actions { automation_action { name = "Canary Slack Notification" url = "https://our-slack-listerner.test/canary-notification" auto_send = true trigger_types = ["alert_triggered"] parameter { key = "channel" value = "#my-team-channel" } parameter { key = "message" value = "something is wrong with the canary deployment" } header { key = "X-Notification-Source" value = "PagerDuty Incident Webhook" } } } } rule { label = "Never bother the on-call for info-level events outside of work hours, and let an Automation Action fix it instead" condition { ``` -------------------------------- ### Get User Sessions Source: https://github.com/pagerduty/terraform-provider-pagerduty/blob/master/website/docs/guides/pagerduty_api_support_status.html.markdown Retrieves all active sessions for a specific user. ```APIDOC ## GET /users/{id}/sessions ### Description Retrieves all active sessions for a specific user. ### Method GET ### Endpoint /users/{id}/sessions ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the user. ```