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

add ability to read an organization membership by org membership id #1036

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AmineChikhaoui
Copy link

This will be useful in case you need to read all organization memberships and pull out information such as emails of all users so that it can be used to create downstream resources, example:

data "tfe_organization_members" "users" {
  organization = var.tfc_org
}

data "tfe_organization_membership" "test" {
  for_each = toset([
    for index, member in data.tfe_organization_members.users.members :
    member.organization_membership_id
  ])
  organization               = var.tfc_org
  organization_membership_id = each.value
}

output "user_emails" {
  value =  [
    for index, member in data.tfe_organization_membership.test :
    member.email
  ]
}

Related issue: #871

Description

Describe why you're making this change.

Remember to:

Testing plan

  1. Describe how to replicate
  2. the conditions
  3. under which your code performs its purpose,
  4. including example Terraform configs where necessary.

External links

Include any links here that might be helpful for people reviewing your PR. If there are none, feel free to delete this section.

Output from acceptance tests

Please run applicable acceptance tests locally and include the output here. See testing.md to learn how to run acceptance tests.

If you are an external contributor, your contribution(s) will first be reviewed before running them against the project's CI pipeline.

$ TESTARGS="-run TestAccTFEWorkspace" make testacc

...

@AmineChikhaoui AmineChikhaoui requested a review from a team as a code owner September 1, 2023 16:19
@hashicorp-cla
Copy link

hashicorp-cla commented Sep 1, 2023

CLA assistant check
All committers have signed the CLA.

This will be useful in case you need to read all organization
memberships and pull out information such as emails of all users so that
it can be used to create downstream resources, example:

```terraform
data "tfe_organization_members" "users" {
  organization = var.tfc_org
}

data "tfe_organization_membership" "test" {
  for_each = toset([
    for index, member in data.tfe_organization_members.users.members :
    member.organization_membership_id
  ])
  organization               = var.tfc_org
  organization_membership_id = each.value
}

output "user_emails" {
  value =  [
    for index, member in data.tfe_organization_membership.test :
    member.email
  ]
}
```

Related issue: hashicorp#871
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants