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

integration_pagerduty: fix perpetual diff in api_token #518

Merged
merged 3 commits into from
Jun 3, 2020

Conversation

bendrucker
Copy link
Contributor

This PR fixes a perpetual diff observed in datadog_integration_pagerduty.api_token, when this value is unset:

- api_token           = (sensitive value)

I called the API and realized that it is returning a redacted string even though this is unset:

$ https get https://api.datadoghq.com/api/v1/integration/pagerduty "DD-API-KEY: ${DATADOG_API_KEY}" "DD-APPLICATION-KEY: ${DATADOG_APP_KEY}"
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Encoding: gzip
Content-Security-Policy: frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report
Content-Type: application/json
DD-POOL: dogweb
Date: Fri, 22 May 2020 19:44:14 GMT
Pragma: no-cache
Set-Cookie: DD-PSHARD=113; Max-Age=604800; Path=/; expires=Fri, 29-May-2020 19:44:14 GMT; secure; HttpOnly
Strict-Transport-Security: max-age=15724800;
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-DD-Debug: PKDIrz8Hcluof9oNzY3q1BouPTowe6nlZ4slm6KLsMEc/9DaK1hteKVCh6mza/IQ
X-DD-VERSION: 35.2535746
X-Frame-Options: SAMEORIGIN

{
    "api_token": "*****",
    "schedules": [],
    "services": [],
    "subdomain": "foo"
}

So when Read persists this value to state, Terraform believes that it needs to remove a remotely set value.

Instead, because a real value is never returned, this attribute should not be set in Read. This means that Terraform cannot detect drift, but if a user updates the value Terraform will still call Update.

Acceptance test output:

$ make cassettes TESTARGS='-run TestAccDatadogIntegrationPagerduty'
==> Checking that code complies with gofmt requirements...
RECORD=true TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccDatadogIntegrationPagerduty -timeout 120m
?   	github.com/terraform-providers/terraform-provider-datadog	[no test files]
=== RUN   TestAccDatadogIntegrationPagerdutyServiceObject_Basic
--- PASS: TestAccDatadogIntegrationPagerdutyServiceObject_Basic (7.92s)
=== RUN   TestAccDatadogIntegrationPagerduty_Basic
--- PASS: TestAccDatadogIntegrationPagerduty_Basic (1.90s)
=== RUN   TestAccDatadogIntegrationPagerduty_TwoServices
--- PASS: TestAccDatadogIntegrationPagerduty_TwoServices (1.87s)
=== RUN   TestAccDatadogIntegrationPagerduty_Migrate2ServiceObjects
--- PASS: TestAccDatadogIntegrationPagerduty_Migrate2ServiceObjects (6.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-datadog/datadog	18.205s
?   	github.com/terraform-providers/terraform-provider-datadog/version	[no test files]

@ghost ghost added size/XS size/XXL and removed size/XS labels May 22, 2020
Copy link
Contributor

@gzussa gzussa left a comment

Choose a reason for hiding this comment

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

Good catch and it seems legit. Thank a lot

@gzussa gzussa merged commit c4cd352 into DataDog:master Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants