PagerDuty / terraform-provider-pagerduty

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

Add integration_email to service_integration data source #584

Open bennyrw opened 2 years ago

bennyrw commented 2 years ago

Terraform Version

Terraform v1.2.7 on darwin_amd64

Affected Resource(s)

Terraform Configuration Files


#
# This first section is applied using a full-access API key in a Terraform project managing all our application environments
#

locals {
  managed_envs = ["production", "staging", "demo"]
}

# n.b. haven't included pagerduty_escalation_policy and users - any should do

resource "pagerduty_service" "environments" {
  for_each = toset(local.managed_envs)

  name                    = each.value
  auto_resolve_timeout    = "null"
  acknowledgement_timeout = "null"
  escalation_policy       = pagerduty_escalation_policy.default.id
  alert_creation          = "create_alerts_and_incidents"
}

data "pagerduty_vendor" "email" {
  name = "Email"
}

resource "pagerduty_service_integration" "email" {
  for_each = toset(local.managed_envs)

  name              = data.pagerduty_vendor.email.name
  service           = pagerduty_service.environments[each.key].id
  vendor            = data.pagerduty_vendor.email.id
  integration_email = "${each.key}-alerts@mycompany.eu.pagerduty.com"
}

#
# The following are then run using a read-only API key in each managed environment
#

data "pagerduty_service_integration" "email" {
  # lookup the integration key we need to link our alerts into PagerDuty
  service_name        = terraform.workspace.  # e.g. "staging"
  integration_summary = "Email"
}

output "test_email_integ_key" {
  value     = data.pagerduty_service_integration.email.integration_key
  sensitive = true
}

Expected Behavior

pagerduty_service_integration data source should include integration_email attribute, like the pagerduty_service_integration resource does.

OR

The integration_key contains the email.

Actual Behavior

pagerduty_service_integration data source only includes integration_key, which is empty for email service integrations

integration_email is not a supported attribute

Steps to Reproduce

  1. terraform apply first section in one project
  2. terraform apply second section in another project
  3. terraform output -json and note the test_email_integ_key value is empty

Thanks for your time

ohookins commented 1 year ago

I'm also suffering from the lack of the email address from the integration_key field of the pagerduty_service_integration data source - is it possible to get from another data source (i.e. I'm misusing it) or is this just a bug?