From fb1792f9a4240a3b1907481fc593863d9cdd9c58 Mon Sep 17 00:00:00 2001 From: Andrew Babichev Date: Fri, 6 Dec 2024 18:33:48 +0000 Subject: [PATCH] fix: drop data source in favour of id reference --- README.md | 6 ++---- data.tf | 11 ----------- defaults.tftest.hcl | 4 ++-- examples/business-service/README.md | 2 +- examples/business-service/main.tf | 2 +- examples/technical-service/README.md | 2 +- examples/technical-service/main.tf | 2 +- main.tf | 4 ++-- variables.tf | 8 ++++---- 9 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 data.tf diff --git a/README.md b/README.md index 4267095..8dc5327 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,6 @@ No modules. | [pagerduty_service.default](https://registry.terraform.io/providers/pagerduty/pagerduty/latest/docs/resources/service) | resource | | [pagerduty_service_dependency.dependent](https://registry.terraform.io/providers/pagerduty/pagerduty/latest/docs/resources/service_dependency) | resource | | [pagerduty_service_dependency.supporting](https://registry.terraform.io/providers/pagerduty/pagerduty/latest/docs/resources/service_dependency) | resource | -| [pagerduty_escalation_policy.default](https://registry.terraform.io/providers/pagerduty/pagerduty/latest/docs/data-sources/escalation_policy) | data source | -| [pagerduty_team.default](https://registry.terraform.io/providers/pagerduty/pagerduty/latest/docs/data-sources/team) | data source | ## Inputs @@ -104,14 +102,14 @@ No modules. | [auto\_resolve\_timeout](#input\_auto\_resolve\_timeout) | PagerDuty service incident auto resolution time in seconds. | `string` | `"null"` | no | | [business](#input\_business) | PagerDuty business service vs technical service switch. | `bool` | `false` | no | | [description](#input\_description) | PagerDuty service description. | `string` | `"Managed by Terraform"` | no | -| [escalation\_policy\_name](#input\_escalation\_policy\_name) | PagerDuty service escalation policy name. | `string` | `null` | no | +| [escalation\_policy\_id](#input\_escalation\_policy\_id) | PagerDuty service escalation policy ID. | `string` | `null` | no | | [incident\_urgency\_rule](#input\_incident\_urgency\_rule) | PagerDuty service incident urgency rule. |
object({
type = string
urgency = optional(string)
during_support_hours = optional(object({
type = string
urgency = string
}))
outside_support_hours = optional(object({
type = string
urgency = string
}))
})
| `null` | no | | [name](#input\_name) | PagerDuty service name | `string` | n/a | yes | | [point\_of\_contact](#input\_point\_of\_contact) | PagerDuty business service point fo contact. | `string` | `null` | no | | [scheduled\_actions](#input\_scheduled\_actions) | PagerDuty service incident escalation actions related within support hours. |
object({
type = optional(string, "urgency_change")
to_urgency = string
at = object({
type = optional(string, "named_time")
name = string
})
})
| `null` | no | | [service\_graph](#input\_service\_graph) | PagerDuty service graph components. |
object({
dependent_services = optional(list(object({
name = string
id = string
type = string
})))
supporting_services = optional(list(object({
name = string
id = string
type = string
})))
})
|
{
"dependent_services": [],
"supporting_services": []
}
| no | | [support\_hours](#input\_support\_hours) | PagerDuty service support hours. |
object({
type = optional(string, "fixed_time_per_day")
time_zone = string
days_of_week = list(number)
start_time = string
end_time = string
})
| `null` | no | -| [team\_name](#input\_team\_name) | PagerDuty business service owner team (Business/Enterprise plan). | `string` | `null` | no | +| [team\_id](#input\_team\_id) | PagerDuty business service owner team ID (Business/Enterprise plan). | `string` | `null` | no | ## Outputs diff --git a/data.tf b/data.tf deleted file mode 100644 index c14cb26..0000000 --- a/data.tf +++ /dev/null @@ -1,11 +0,0 @@ -data "pagerduty_escalation_policy" "default" { - count = var.business ? 0 : 1 - - name = var.escalation_policy_name -} - -data "pagerduty_team" "default" { - count = var.business ? 1 : 0 - - name = var.team_name -} diff --git a/defaults.tftest.hcl b/defaults.tftest.hcl index 8e38773..ed1ae8a 100644 --- a/defaults.tftest.hcl +++ b/defaults.tftest.hcl @@ -1,8 +1,8 @@ # mock_provider "pagerduty" {} variables { - name = "Test" - escalation_policy_name = "Primary" + name = "Test" + escalation_policy_id = "PBNPJZC" } run "defaults" { diff --git a/examples/business-service/README.md b/examples/business-service/README.md index ae00f4a..bb9df6f 100644 --- a/examples/business-service/README.md +++ b/examples/business-service/README.md @@ -4,7 +4,7 @@ A basic [PagerDuty business service](https://support.pagerduty.com/main/docs/bus ## Prerequisites -* PagerDuty **team** resource has to be applied. +* PagerDuty **team** resource must exist. ## Usage diff --git a/examples/business-service/main.tf b/examples/business-service/main.tf index 9ec07a3..c01afce 100644 --- a/examples/business-service/main.tf +++ b/examples/business-service/main.tf @@ -6,5 +6,5 @@ module "example" { name = "Acme Corp Mega Service" description = "The Acme Corp Mega Service is the most important service in the company." point_of_contact = "acme@example.com" - team_name = "Platform" + team_id = "P8OZ082" } diff --git a/examples/technical-service/README.md b/examples/technical-service/README.md index 687c780..562f6bd 100644 --- a/examples/technical-service/README.md +++ b/examples/technical-service/README.md @@ -4,7 +4,7 @@ A basic [PagerDuty technical service](https://support.pagerduty.com/main/docs/se ## Prerequisites -* PagerDuty **escalation policy** resource has to be applied. +* PagerDuty **escalation policy** resource must exist. ## Usage diff --git a/examples/technical-service/main.tf b/examples/technical-service/main.tf index 65a482f..b608ab7 100644 --- a/examples/technical-service/main.tf +++ b/examples/technical-service/main.tf @@ -2,7 +2,7 @@ module "example" { source = "../../" name = "Example" - escalation_policy_name = "Primary" + escalation_policy_name = "PBNPJZC" auto_resolve_timeout = 3600 acknowledgement_timeout = 600 diff --git a/main.tf b/main.tf index 87bca59..20b67a7 100644 --- a/main.tf +++ b/main.tf @@ -4,7 +4,7 @@ resource "pagerduty_business_service" "default" { name = var.name description = var.description point_of_contact = var.point_of_contact - team = data.pagerduty_team.default[0].id + team = var.team_id } resource "pagerduty_service" "default" { @@ -12,7 +12,7 @@ resource "pagerduty_service" "default" { name = var.name description = var.description - escalation_policy = data.pagerduty_escalation_policy.default[0].id + escalation_policy = var.escalation_policy_id auto_resolve_timeout = var.auto_resolve_timeout acknowledgement_timeout = var.acknowledgement_timeout diff --git a/variables.tf b/variables.tf index d01c4ba..5bccf28 100644 --- a/variables.tf +++ b/variables.tf @@ -4,10 +4,10 @@ variable "business" { description = "PagerDuty business service vs technical service switch." } -variable "team_name" { +variable "team_id" { type = string default = null - description = "PagerDuty business service owner team (Business/Enterprise plan)." + description = "PagerDuty business service owner team ID (Business/Enterprise plan)." } variable "point_of_contact" { @@ -27,10 +27,10 @@ variable "description" { description = "PagerDuty service description." } -variable "escalation_policy_name" { +variable "escalation_policy_id" { type = string default = null - description = "PagerDuty service escalation policy name." + description = "PagerDuty service escalation policy ID." } variable "acknowledgement_timeout" {