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_api_key] Fix bug introduced in 3.55.0 for organisation that doesn't have Remove config enabled #2857

Merged
merged 5 commits into from
Feb 24, 2025

Conversation

ecdatadog
Copy link
Contributor

@ecdatadog ecdatadog commented Feb 21, 2025

Fixes #2847

Remove config is configured globally at org level (see /organization-settings/remote-config).

  • When it is not enabled, the remote_config_read_enabled argument of api_key is always set to false
  • When it is enabled, the remote_config_read_enabled argument is set by default to true but can be set explicitly to false

Proposed fix :

  • When the user don't set remote_config_read_enabled , it will be the default value (true if RC is enabled, false if not) . Similar behavior as in <3.55.0
  • When the user set remote_config_read_enabled to false , it will always works
  • When the user set remote_config_read_enabled to true,
    • it will succeeds if RC is enabled at org level
    • it will fails if RC is not enabled at org level

You will get this error if you set the argument while RC is not enabled at org level :

╷
│ Error: remote_config_read_enabled is true but Remote config is not enabled at org level
│ 
│   with datadog_api_key.rctrue,
│   on api.tf line 5, in resource "datadog_api_key" "rctrue":
│    5: resource "datadog_api_key" "rctrue" {
│ 
│ Please either remove remote_config_read_enabled from the resource configuration or enable Remote config at org level
╵

@ecdatadog ecdatadog requested review from a team as code owners February 21, 2025 07:20
@ecdatadog ecdatadog requested review from justlo and emubello February 21, 2025 07:20
Supam
Supam previously approved these changes Feb 21, 2025
tyjet
tyjet previously approved these changes Feb 21, 2025
@hestonhoffman hestonhoffman self-assigned this Feb 21, 2025
Copy link

@aliciascott aliciascott left a comment

Choose a reason for hiding this comment

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

Hi @ecdatadog looks good just a small suggestion, let me know when this is ready for re-review thanks!

@@ -28,7 +28,7 @@ resource "datadog_api_key" "foo" {

### Optional

- `remote_config_read_enabled` (Boolean) Whether the API key is used for remote config. Warning : default value is true for backwards compatibility Defaults to `true`.
- `remote_config_read_enabled` (Boolean) Whether the API key is used for remote config. Should be put to true only if remote config is enabled in /organization-settings/remote-config

Choose a reason for hiding this comment

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

Suggested change
- `remote_config_read_enabled` (Boolean) Whether the API key is used for remote config. Should be put to true only if remote config is enabled in /organization-settings/remote-config
- `remote_config_read_enabled` (Boolean) Whether the API key is used for remote config. Set to true if remote config is enabled in `/organization-settings/remote-config`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took in account but add only : Set to true only if

Copy link
Contributor

@hestonhoffman hestonhoffman left a comment

Choose a reason for hiding this comment

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

Left you a small suggestion Nvm, looks like Alicia got to this one :)

@hestonhoffman hestonhoffman requested review from hestonhoffman and removed request for hestonhoffman February 21, 2025 16:52
@hestonhoffman hestonhoffman removed their assignment Feb 21, 2025
@hestonhoffman hestonhoffman removed their request for review February 21, 2025 23:22
@ecdatadog ecdatadog dismissed stale reviews from tyjet and Supam via 481bb7b February 24, 2025 05:57
Copy link

@aliciascott aliciascott left a comment

Choose a reason for hiding this comment

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

looks good

@ecdatadog ecdatadog requested a review from Supam February 24, 2025 16:19
@ecdatadog ecdatadog merged commit 9789e64 into master Feb 24, 2025
10 checks passed
@ecdatadog ecdatadog deleted the fix_api_key_rc branch February 24, 2025 16:46
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.

datadog_api_key Error: Provider produced inconsistent result after apply
5 participants