Skip to content
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

add integration datasource #363

Merged
merged 8 commits into from
Aug 16, 2021

Conversation

petetanton
Copy link
Contributor

@petetanton petetanton commented Jul 29, 2021

This PR adds support for data.pagerduty_service_integration so that integration keys can be fetched from PagerDuty when configuring alerts from third party systems in Terraform

Example usage:

data "pagerduty_integration" pdint {
  service_name = "my-service-name"
  integration_summary = "Amazon CloudWatch"
}

@petetanton petetanton marked this pull request as ready for review July 30, 2021 12:55
@petetanton
Copy link
Contributor Author

@stmcallister please can I get a review on this? I am not sure exactly what the process is but more than happy add any clarification if required!

Copy link
Member

@gsreynolds gsreynolds left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for adding the documentation too 🎉

Test results:

TF_ACC=1 go test -run "TestAccDataSourcePagerDutyIntegration_Basic" ./pagerduty -v -timeout 120m
=== RUN   TestAccDataSourcePagerDutyIntegration_Basic
--- PASS: TestAccDataSourcePagerDutyIntegration_Basic (8.28s)
PASS
ok      github.com/terraform-providers/terraform-provider-pagerduty/pagerduty   9.008s


return nil
}

Copy link
Contributor

@stmcallister stmcallister Aug 14, 2021

Choose a reason for hiding this comment

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

When I first saw the setupResources function I thought, "wow! what a super clean way to do this!" But after running the tests a few times I discovered why we don't do it this way through out the rest of the provider. When you create the objects directly through the client then the Terraform test suite doesn't manage them. So, when the tests are done all these created objects still exist on the PagerDuty account. When you define these objects in the HCL below then Terraform Testing will manage them correctly (ie, create the objects and then delete them when the test is complete.

Please move the creation of these dependent objects to the HCL below. (Good example is in the data_source_pagerduty_service_test). Otherwise, the PR looks great. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I have tried to implement your suggestion.
I ended up doing a test within a test so that resources created in the first plan can be reference by the second plan.
I am new to terraform testing so please feel free to suggest alternatives!

Thanks
Pete

Copy link
Contributor

@stmcallister stmcallister left a comment

Choose a reason for hiding this comment

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

It is a different approach than the other tests, but from what I can tell it seems to do the job. Thanks for adding this feature to the provider!! 👍 🎉

@stmcallister stmcallister merged commit 4742e9b into PagerDuty:master Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants