Skip to content

[datadog_integration_pagerduty_service_object] Add data source for pagerduty service objects #1773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

nkzou
Copy link
Contributor

@nkzou nkzou commented Feb 10, 2023

Supersedes #1771, Original PR by @scemily13

Adds the pagerduty_integration_service_object datasource to query for its existence so as to determine whether or not to create the same integration again.

Original issue: #1718

hestonhoffman
hestonhoffman previously approved these changes Feb 10, 2023
Copy link
Contributor

@hestonhoffman hestonhoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit

@scemily13
Copy link

Hi @hestonhoffman @nkzou -- any updates on this?

Copy link
Contributor

@hestonhoffman hestonhoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nkzou
Copy link
Contributor Author

nkzou commented Feb 23, 2023

Hi there, we've looked into the PR and we don't think the data source works as expected. The goal was to query the existence of the service object to avoid recreating it in a different terraform project/state, right? The given example code doesn't accomplish that, because the logic length(data.datadog_integration_pagerduty_service_object.foo) > 0 ? 1 : 0 will still try to recreate the object if run in a different terraform state.

Moving forward we plan on changing the data source to one that returns a list of all pagerduty service objects, though I don't expect this to fit your use case either, since I believe this pattern goes against terraform's design. See hashicorp/terraform#23178 (comment). Could you share a bit more about your environment and use case? Multiple terraform states should not be attempting to manage a single object.

Hopefully that all made sense and explains why we're not moving forward with the PR as it is now, let me know if I've misunderstood anything.

@skang0601
Copy link

Moving forward we plan on changing the data source to one that returns a list of all pagerduty service objects, though I don't expect this to fit your use case either, since I believe this pattern goes against terraform's design.

That would still work for our use case but that looks like it would require a change in the API since it only allows for looking up a single integration.

Could you share a bit more about your environment and use case? Multiple terraform states should not be attempting to manage a single object.

We're distributing out a Terraform module for managing a PD service object in Pagerduty and then setting up the integration in Datadog. This standardizes the naming of these resources and allows us to also deterministically output the routing string (@pagerduty-*) for usage in their monitors.

Our general setup is that each team/application maintains their own Terraform repository/state for their monitoring setup. But certain teams may want to define monitors in their codebase but route the alert to another's team Pagerduty service, so currently, they'll use the same module for creating the Pagerduty service/integration but pass a flag to the module to disable the creation of the service/integration to just get the routing string.

This setup has caused confusion for people since it requires the users to know if a pagerduty integration already exists and pass in the flag to disable creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants