Skip to content

Conversation

@tquidetdd
Copy link
Contributor

@tquidetdd tquidetdd commented Nov 6, 2025

Description

This PR adds a new exclude_service_accounts attribute to the datadog_user data 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_users data 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:

  • Added exclude_service_accounts boolean attribute to datadog_user data source (defaults to false for backward compatibility)
  • Updated filtering logic to filter out service accounts when this option is enabled
  • Enhanced error messages to indicate when errors occur "after excluding service accounts" for better debugging

Testing

Added test coverage for the new functionality:

  • TestAccDatadogUserDatasourceWithExcludeServiceAccounts - Tests successful filtering of service accounts
  • TestAccDatadogUserDatasourceWithExcludeServiceAccountsMultipleUsersWithError - Tests error handling when multiple non-service-account users remain after filtering
  • TestAccDatadogUserDatasourceWithExcludeServiceAccountsWithError - Tests error handling when users and service accounts remain

What 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.

@tquidetdd tquidetdd marked this pull request as ready for review November 7, 2025 08:25
@tquidetdd tquidetdd requested review from a team as code owners November 7, 2025 08:25
Copy link
Contributor

@LiuVII LiuVII left a comment

Choose a reason for hiding this comment

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

lgtm

btw, is there some existing Github issue asking for this that we can link or this was requested via some other channels?

@tquidetdd
Copy link
Contributor Author

lgtm

btw, is there some existing Github issue asking for this that we can link or this was requested via some other channels?

I don’t see any issues related to this.
We faced this problem when we started importing On-call team configurations into Terraform, and we decided to update the provider instead of creating a module.

@tquidetdd
Copy link
Contributor Author

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Nov 17, 2025

View all feedbacks in Devflow UI.

2025-11-17 12:59:38 UTC ℹ️ Start processing command /merge


2025-11-17 12:59:44 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 28m (p90).


2025-11-17 13:26:10 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit c6532d2 into master Nov 17, 2025
16 checks passed
@dd-mergequeue dd-mergequeue bot deleted the timothee.quidet/datasource-user-exclude-service-account branch November 17, 2025 13:26
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.

5 participants