launchdarkly / terraform-provider-launchdarkly

Terraform LaunchDarkly provider
https://www.terraform.io/docs/providers/launchdarkly/
Mozilla Public License 2.0
22 stars 24 forks source link

Manage `launchdarkly_team_member` where the email exists in more than one `launchdarkly_team` resource. #184

Closed scuba10steve closed 7 months ago

scuba10steve commented 1 year ago

Currently, it appears that the provider tries to create the member if it doesn't exist yet, then add that member to the team. I do have a situation where I have the need to add the same email to multiple teams.

example:

resource "launchdarkly_team_member" "developer" {
  count = length(var.team_members)

  email = element(var.team_members, count.index)
  role = "reader"
}

This is pulled into a module, and then referenced more than once with the same email. e.g.

module "team-a" {
    source "./team"

    team_members = [ "someperson@someorg.com"]
}

module "team-b" {
    source "./team"

    team_members = [ "someperson@someorg.com"]
}

So I'm not expecting that the behavior of the launchdarkly_team_member resource to change, however I would like to be able to map multiple members with the same email. If there's a workaround to do this now, I'm willing to try it.

Example error:

Error: failed to create team member with email: someperson@someorg.com: 400 Bad Request: {"code":"email_already_exists_in_account","message":"Members with the following e-mail addresses already exist in this account: someperson@someorg.com","invalid_emails":["someperson@someorg.com"]} │ │ with module.team-b.launchdarkly_team_member.developer[1], │ on team/team.tf line 10, in resource "launchdarkly_team_member" "developer": │ 10: resource "launchdarkly_team_member" "developer" { │

scuba10steve commented 1 year ago

This can also be triggered if the email exists as an account member, but not associated with any teams.

ldhenry commented 11 months ago

Hey @scuba10steve,

I think the issue is you have multiple modules that are attempting to create the same team member. Would it be possible to create the team members in a different module and pass the relevant team members into a module that just defines the LaunchDarkly team resource?

Sorry for the delayed response, Henry

scuba10steve commented 11 months ago

I believe that may be possible, I found a workaround by importing the member manually for now.