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

Error while creating users #304

Closed
alepuccetti opened this issue May 12, 2022 · 5 comments
Closed

Error while creating users #304

alepuccetti opened this issue May 12, 2022 · 5 comments

Comments

@alepuccetti
Copy link

This issue started happening from the 20th April 2022. Before this error never occurred and the code I use did not changed.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v1.1.9
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.15.0
+ provider registry.terraform.io/hashicorp/googleworkspace v0.6.0

Note: the plans are executed on terraform cloud with the same version.

Affected Resource(s)

Please list the resources as a list, for example:

  • googleworkspace_user

Terraform Configuration Files

resource "googleworkspace_user" "cv-users" {
  for_each = { for user in local.users : user.email => user }

  org_unit_path = "/my_org_unit"

  primary_email = each.value.email
  password      = each.value.password
  hash_function = each.value.password_hash_function

  name {
    family_name = each.value.last_name
    given_name  = each.value.first_name
  }

  recovery_email = each.value.recovery_email

}

Expected Behavior

Create the user and detect its creation.

Actual Behavior

Creates the user and return the following error:

Error: unexpected error during retries of user: googleapi: Error 404: Resource Not Found: userKey, notFound
with module.community_vision.googleworkspace_user.cv-users["USER_EMAIL"]
on my_module/main.tf line 62, in resource "googleworkspace_user" "cv-users":

At this point the resource is marked as tainted and any subsequent re-run will fail.

With Error: googleapi: Error 409: Entity already exists., duplicate, this is because the user is actually created.

The only workaround is to remove the resource from the state and import it back manually:

terraform state rm 'module.my_module.googleworkspace_user.cv-users["USER_EMAIL"]';
terraform import 'module.my_module.googleworkspace_user.cv-users["USER_EMAIL"]' ACCOUNT_ID;

The account ID can be found in the state before removing the resource.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
@ghost
Copy link

ghost commented May 12, 2022

Fighting with that since yesterday.

From debug output I can add:

  • POST seems to work, user is created and API returns HTTP 200
  • GET sends user_ID but fails with 404

Headers during creation

Another workaround is to:

  1. Create user without attaching any other resources
  2. terraform untaint 'google_workspace.user["[email protected]"]'
  3. Add other resources eg. groups to the untainted user
  4. terraform apply

But it shouldn't be done like this.

@alepuccetti
Copy link
Author

@kwasz-sysdogs with my approach you the user get fixed and after that you can re-run terraform apply and the other resources get created correctly. I follow this workflow:

  1. Run the code that I know will fail.
  2. Run the state rm and import step to fix the user.
  3. Rerun terraform apply,

@victuos
Copy link

victuos commented May 13, 2022

Same problem here, workaround is indeed deleting and re importing the users.

But its really breaking our workflow! Any ideas on how this is happening?

@santisaez
Copy link

This is a duplicated of #286 where a fix is being discussed 👍

@megan07
Copy link
Contributor

megan07 commented May 31, 2022

Closing as duplicate of #286

@megan07 megan07 closed this as completed May 31, 2022
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

No branches or pull requests

4 participants