Skip to main content

Hi All, Do we have documentation or a walkthrough on how you can link a business service to multiple technical services using terraform?

Hello @obi nwagu! Thanks for reaching out.


I have looked into the documentation for Business Service and Technical Service and I don’t see a way to do that in Terraform. But I might be missing something.


@josé antonio reyes can you help us understand if it is possible to use Terraform to link Technical Services to a Business Service? Thanks in advance!


Hey @tiago barbosa and @obi nwagu


Yeap! You can configure your Business Service dependencies topology using Terraform through use of the pagerduty_service_dependency resource, like follows…


# Assuming this is an actual Business Service you already have configured in
# you PagerDuty environment
data "pagerduty_business_service" "bs" {
name = "Your Business Case"
}

# In the other hand, these are the Technical Service You want to configure as
# supporting Services for you Business Case.
data "pagerduty_service" "foo" {
name = "foo"
}
data "pagerduty_service" "bar" {
name = "bar"
}
data "pagerduty_service" "baz" {
name = "baz"
}
data "pagerduty_service" "foobar" {
name = "foobar"
}


resource "pagerduty_service_dependency" "bs_foo" {
dependency {
dependent_service {
id = data.pagerduty_business_service.bs.id
type = "business_service"
}
supporting_service {
id = data.pagerduty_service.foo.id
type = data.pagerduty_service.foo.type
}
}
}
resource "pagerduty_service_dependency" "bs_bar" {
dependency {
dependent_service {
id = data.pagerduty_business_service.bs.id
type = "business_service"
}
supporting_service {
id = data.pagerduty_service.bar.id
type = data.pagerduty_service.bar.type
}
}
}

# This is the same, but dynamic using a local variable, which can help you to
# reduce code redundancy
locals {
srv_refs = =
data.pagerduty_service.foo.id,
data.pagerduty_service.bar.id,
data.pagerduty_service.baz.id,
data.pagerduty_service.foobar.id,
]
}

resource "pagerduty_service_dependency" "bs_tech_deps" {
for_each = local.srv_refs

dependency {
dependent_service {
id = data.pagerduty_business_service.bs.id
type = "business_service"
}
supporting_service {
id = each.value
type = "service"
}
}
}


Same logic applies for dependencies between Technical services.


Great! I thought this would only apply to Technical Services. It is clear now. Thanks @josé antonio reyes!


@obi nwagu does this answer your question?


Reply