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

How can I make a user a member of "Domain Admins" without importing to state? #88

Open
Lucero7919 opened this issue Mar 9, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@Lucero7919
Copy link

Description

Group Memberships works fine for groups created through TF, but I would like to add a user to an OOB AD Domain Group (Domain Admins). Ideally, I don't want to import this group into state first and as it wasn't created by TF, I don't think a Data call will work.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@Lucero7919 Lucero7919 added the enhancement New feature or request label Mar 9, 2021
@jpatigny
Copy link
Contributor

Hello @Lucero7919,

You can use a group datasource to select the group for the membership resource and and user datasource(s) to get existing users

Example:

Adding an existing user to built-in group "Domain Admins"

data "ad_group" "domain_admins" {
    group_id = "CN=Domain Admins,CN=Users,DC=jej,DC=net"
}

data "ad_user" "da1" {
    user_id = "jej"
}

resource ad_group_membership "gm" {
    group_id = data.ad_group.domain_admins.sam_account_name
    group_members  = [ data.ad_user.da1.sam_account_name ]
}

@Nothing4You
Copy link

That example above is currently not reliable, see #94.
A workaround would be referencing group members with .id instead of .sam_account_name .

@Lucero7919 is your intention to keep existing users in the group and only manage additional members via terraform next to unmanaged ones or just replace the full member list?
Replacing works just fine this way, this is exactly what data sources are intended for, partially managing the member list does not work this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants