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

[datadog_application_key] Add deprecation warning to datadog_application_key data source #2465

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

jackakeller
Copy link
Contributor

@jackakeller jackakeller commented Jun 27, 2024

Add new deprecation message to datadog_application_key data source.

Followed these guidelines: https://developer.hashicorp.com/terraform/plugin/framework/deprecations#provider-data-source-or-resource-removal

Tested locally.

Warning when deprecated data source is used:

=> terraform plan
datadog_application_key.jackakeller-foo: Refreshing state... [id=ad77b716-c871-4e94-bb53-cef5ed244551]
data.datadog_application_key.foo: Reading...
data.datadog_application_key.foo: Read complete after 0s [id=ad77b716-c871-4e94-bb53-cef5ed244551]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
╷
│ Warning: Deprecated
│
│   with data.datadog_application_key.foo,
│   on main.tf line 24, in data "datadog_application_key" "foo":
│   24: data "datadog_application_key" "foo" {
│
│ The datadog_application_key data source is deprecated and will be removed in a future release with prior notice. Securely store your application key using a secret management
│ system or use the datadog_application_key resource to manage application keys in your Datadog account.
│

This also is printed for terraform refresh and terraform apply. On either refresh or apply the key is still stored in Terraform state.

Error when deprecated source is used and application key is not provided from the datadog API:

=> terraform plan
data.datadog_application_key.foo: Reading...
datadog_application_key.jackakeller-foo: Refreshing state... [id=ad77b716-c871-4e94-bb53-cef5ed244551]

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Warning: Deprecated
│
│   with data.datadog_application_key.foo,
│   on main.tf line 24, in data "datadog_application_key" "foo":
│   24: data "datadog_application_key" "foo" {
│
│ The datadog_application_key data source is deprecated and will be removed in a future release with prior notice. Securely store your application key using a secret management
│ system or use the datadog_application_key resource to manage application keys in your Datadog account.
│
│ (and one more similar warning elsewhere)
╵
╷
│ Error: Deprecated
│
│   with data.datadog_application_key.foo,
│   on main.tf line 24, in data "datadog_application_key" "foo":
│   24: data "datadog_application_key" "foo" {
│
│ The datadog_application_key data source is deprecated and will be removed in a future release. Securely store your application key using a secret management system or use the
│ datadog_application_key resource to manage application keys in your Datadog account.

This also is printed for terraform refresh and terraform apply.

Testing note:

If in the future we stop returning the key field, then the integration tests will start failing. This is okay because at that point the data source is no longer functional and the tests can be removed.

Note:

We are not going to simply preserve pre-existing data sources by not overwriting the key value like for the resource here.

Right now, if you configure a data source based on the name, then it reads the current state from that name and overwrites key and UUID. In other words, it's always up to date with Datadog.

This means if you delete an app key that is already configured as a data source, and then create a new one with the same name, you'll get the new app key UUID and key.

If we preserve the original key's raw value, you could get the new UUID but have the old key value. Similarly, if we were to stop updating both UUID and key, then the name also wouldn't match current state. This would cause state drift.

(This is not a problem for imported resources because those import based solely on UUID, and name can still be read on future refreshes even without the key field)

@jackakeller jackakeller force-pushed the jackakeller/deprecate-application-key-data-source branch 3 times, most recently from b426fd3 to b165872 Compare June 28, 2024 16:20
@jackakeller jackakeller changed the title Add deprecation message to datadog_application_key data source Add deprecation warning to datadog_application_key data source Jun 28, 2024
@jackakeller jackakeller force-pushed the jackakeller/deprecate-application-key-data-source branch 3 times, most recently from cd1adaf to cf8b8ec Compare July 10, 2024 15:49
@jackakeller jackakeller marked this pull request as ready for review July 10, 2024 16:01
@jackakeller jackakeller requested review from a team as code owners July 10, 2024 16:01
@jackakeller jackakeller requested a review from a team July 10, 2024 16:14
tyjet
tyjet previously approved these changes Jul 10, 2024
buraizu
buraizu previously approved these changes Jul 10, 2024
…ror if the application key is not provided from the datadog API.
@jackakeller jackakeller dismissed stale reviews from buraizu and tyjet via fcfe231 July 10, 2024 21:28
@jackakeller jackakeller force-pushed the jackakeller/deprecate-application-key-data-source branch from cf8b8ec to fcfe231 Compare July 10, 2024 21:28
Copy link

@adityab-datadog adityab-datadog 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 nkzou changed the title Add deprecation warning to datadog_application_key data source [datadog_application_key] Add deprecation warning to datadog_application_key data source Jul 11, 2024
@nkzou nkzou merged commit 7580236 into master Jul 11, 2024
11 checks passed
@nkzou nkzou deleted the jackakeller/deprecate-application-key-data-source branch July 11, 2024 14:41
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.

5 participants