[datadog_user] Add new exclude_service_accounts attribute to the datadog_user ds #3323
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.
Description
This PR adds a new
exclude_service_accountsattribute to thedatadog_userdata source.This boolean option allows users to filter out service accounts from user search results, making it easier to query for regular user accounts without having to manually filter by using the
dataodg_usersdata source and then manually exclude service accounts.Motivation: When querying users by email, service accounts with matching attributes cause an error
your query returned more than one result for filter.This new attribute provides a clean way to exclude service accounts directly in the data source query.
This is useful in the context of the Datadog On-call product, since we often need to retrieve users to add them to a schedule, and we don’t want to include service accounts in an On-call schedule.
Changes:
exclude_service_accountsboolean attribute todatadog_userdata source (defaults tofalsefor backward compatibility)Testing
Added test coverage for the new functionality:
TestAccDatadogUserDatasourceWithExcludeServiceAccounts- Tests successful filtering of service accountsTestAccDatadogUserDatasourceWithExcludeServiceAccountsMultipleUsersWithError- Tests error handling when multiple non-service-account users remain after filteringTestAccDatadogUserDatasourceWithExcludeServiceAccountsWithError- Tests error handling when users and service accounts remainWhat will it impact?
This is a new optional attribute with backward compatibility. Existing configurations will be unaffected as the default value is
false. Users who enable this feature will see filtered results excluding service accounts.