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

can't provision with tfe_organization_membership due to drift detection(delete) #1101

Open
wetwicky opened this issue Oct 11, 2023 · 0 comments
Labels

Comments

@wetwicky
Copy link

Terraform Cloud/Enterprise version

tfe v0.44.1

Terraform version

Terraform version: 1.6.1
Go runtime version: go1.21.1

Terraform Configuration Files

resource "tfe_organization_membership" "tfc_mycompany_sso_members" {
  organization = "mycompany"
  email        = firstname.lastname@mycompany.com
}

Debug Output

during the first apply, the resource is created and added to the state but in later runs, during the plan the user_id or the username or the id change which cause a drift and it removes the resource from the state but not in the provider portal...this causes an error which says resource already exist which requires manual action to be imported

tfe_organization_membership.tfc_mycompany_sso_members["firstname.lastname@mycompany.com"]: Drift detected (delete)

Terraform will perform the following actions:

# tfe_organization_membership.tfc_mycompany_sso_members["firstname.lastname@mycompany.com"] will be created
  + resource "tfe_organization_membership" "tfc_mycompany_sso_members" {
      + email        = "firstname.lastname@mycompany.com"
      + id           = (known after apply)
      + organization = "mycompany"
      + user_id      = (known after apply)
      + username     = (known after apply)
    }


tfe_organization_membership.tfc_mycompany_sso_members["firstname.lastname@mycompany.com"]: Creating...
╷
│ Error: Error creating membership firstname.lastname@mycompany.com for organization mycompany: invalid attribute
│ 
│ User is already an organization member
│ 
│   with tfe_organization_membership.tfc_mycompany_sso_members["firstname.lastname@mycompany.com"],
│   on main.tf line 59, in resource "tfe_organization_membership" "tfc_mycompany_sso_members":
│   59: resource "tfe_organization_membership" "tfc_mycompany_sso_members" {

Expected Behavior

resource should be update in place instead of deleted, i'm not sure why the Id change but i guess this force a new resource to be created. in this case the unique key should be the email not the id

Actual Behavior

resource is deleted because of drift detection

Additional Context

we don't have control over computed value for the id, user_id, username that change outside of our terraform configuration which makes it difficult to provision terraform cloud.

@wetwicky wetwicky added the bug label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant