[datadog_application_key] Add deprecation warning to datadog_application_key data source #2465
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
This also is printed for
terraform refresh
andterraform apply
. On eitherrefresh
orapply
the key is still stored in Terraform state.Error when deprecated source is used and application key is not provided from the datadog API:
This also is printed for
terraform refresh
andterraform 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)