DataDog / terraform-provider-datadog

Terraform Datadog provider
https://www.terraform.io/docs/providers/datadog/
Mozilla Public License 2.0
399 stars 375 forks source link

[datadog_api_key] Add deprecation warning to datadog_api_key data source #2541

Closed tyjet closed 1 month ago

tyjet commented 1 month ago

Add new deprecation message to datadog_api_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:

data.datadog_api_key.ddiner_test: Reading...
data.datadog_api_key.ddiner_test: Read complete after 1s [id=b4371e76-3361-4034-9b48-f15e7514587f]

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_api_key.ddiner_test,
│   on main.tf line 15, in data "datadog_api_key" "ddiner_test":
│   15: data "datadog_api_key" "ddiner_test" {
│
│ Deprecated. This will be removed in a future release with prior notice. Securely store your API keys using a secret
│ management system or use the datadog_api_key resource to manage API 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:

data.datadog_api_key.ddiner_test: Reading...

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

╷
│ Warning: Deprecated
│
│   with data.datadog_api_key.ddiner_test,
│   on main.tf line 15, in data "datadog_api_key" "ddiner_test":
│   15: data "datadog_api_key" "ddiner_test" {
│
│ Deprecated. This will be removed in a future release with prior notice. Securely store your API keys using a secret
│ management system or use the datadog_api_key resource to manage API keys in your Datadog account.
│
│ (and one more similar warning elsewhere)
╵
╷
│ Error: Deprecated
│
│   with data.datadog_api_key.ddiner_test,
│   on main.tf line 15, in data "datadog_api_key" "ddiner_test":
│   15: data "datadog_api_key" "ddiner_test" {
│
│ The datadog_api_key data source is deprecated and will be removed in a future release. Securely store your API key using a
│ secret management system or use the datadog_api_key resource to manage API 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.

fabienma-ddog commented 1 month ago

Add new deprecation message to datadog_application_key data source.

nit: I think you meant datadog_api_key data source

jack-edmonds-dd commented 1 month ago

/merge

dd-devflow[bot] commented 1 month ago

:steam_locomotive: MergeQueue: pull request added to the queue

The median merge time in master is 1m.

Use /merge -c to cancel this operation!