terraform-provider-tfe icon indicating copy to clipboard operation
terraform-provider-tfe copied to clipboard

add ability to read an organization membership by org membership id

Open AmineChikhaoui opened this issue 2 years ago • 1 comments

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 avatar Sep 01 '23 16:09 AmineChikhaoui

CLA assistant check
All committers have signed the CLA.

hashicorp-cla avatar Sep 01 '23 16:09 hashicorp-cla