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_service_account] Fix : roles attribute is now always updated #2761

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ecdatadog
Copy link

Closes #2736

Current behaviour

If you ask for a service_account without roles

resource "datadog_service_account" "bar" {
  email = "etienne.carriere@datadoghq.com"
  name  = "Terraform test"
}

the drift will never be detected :

  • At the creation, as there is no role defined, state.Roles is null
  • If there is a manual change on service-account object by adding a role, at the next refresh of state, the state.Roles is still null and will not be refreshed

If you ask a service_account with at least one role, the issue doesn't happens as the State will not be null

Similarly if you import a service_account, Roles will never be loaded

Proposed behavior

Update in all cases the state.Roles from the result so we :

Risks of drift creation

When is called updateServiceAccountStateV2 ?

  • 2 times in Create after creation
  • 1 time in Read
  • 1 time in Update after update
    => the change should not have drift impact

As the roles parameter is optional and computed, if the user is requesting no specific roles and there is some automatic assignements it should not be seen as diff.

@ecdatadog ecdatadog requested review from a team as code owners January 13, 2025 12:43
@ecdatadog ecdatadog changed the title Resource service_account roles not properly handled Bugfix : Updating roles in service_account is not always properly done Jan 13, 2025
@ecdatadog ecdatadog changed the title Bugfix : Updating roles in service_account is not always properly done [datadog_service_account] roles attribute is now always updated Jan 13, 2025
@ecdatadog ecdatadog changed the title [datadog_service_account] roles attribute is now always updated [datadog_service_account] Fix : roles attribute is now always updated Jan 14, 2025
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.

Imported datadog_service_account resources are missing their roles
1 participant