Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

terraform plan fails when gsuite group is "manually" removed #107

Open
opdecirkel opened this issue Oct 18, 2019 · 2 comments
Open

terraform plan fails when gsuite group is "manually" removed #107

opdecirkel opened this issue Oct 18, 2019 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@opdecirkel
Copy link

opdecirkel commented Oct 18, 2019

When creating gsuite_group and accompanying gsuite_group_members using terraform and (this) gsuite provider, then remove the group (outside terraform, e.g. using the admin UI), terraform plan fails with Error: googleapi: Error 404: Resource Not Found: groupKey, notFound

How to reproduce:

  1. Create terraform module for the group:
provider "gsuite" {
  impersonated_user_email = "[email protected]"
  oauth_scopes = [
    "https://www.googleapis.com/auth/admin.directory.group",
    "https://www.googleapis.com/auth/admin.directory.user"
  ]
}
resource "gsuite_group" "tf-plugin-error" {
  email       = "[email protected]"
  name        = "Tf Plugin Error"
  description = "Reproduce Gsuite Tf Plugin Error"
}
resource "gsuite_group_members" "tf-plugin-error" {
  group_email = gsuite_group.tf-plugin-error.email

  member {
    email = "[email protected]"
    role = "OWNER"
  }
}
  1. Run terraform apply
  2. Go to https://admin.google.com or https://groups.google.com and remove the group
  3. Running terrafoorm plan will fail with:
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

gsuite_group.tf-plugin-error: Refreshing state... [id=049x2ik52rn0w79]
gsuite_group_members.tf-plugin-error: Refreshing state... [[email protected]]

Error: googleapi: Error 404: Resource Not Found: groupKey, notFound
$ terraform version
Terraform v0.12.10
+ provider.gsuite v0.1.34
@DeviaVir
Copy link
Owner

Not sure if you care but the group id of your domain is in the step 4 code.

I think you can work around this now by using a simple terraform state rm gsuite_group_members.tf-plugin-error but we should do something better here

@opdecirkel
Copy link
Author

@DeviaVir That is a workaround I use, but when you have many groups it hard to find what actually broke because the log message does not say.
Also if this is part of automated workflow, it breaks it

@DeviaVir DeviaVir added bug Something isn't working enhancement New feature or request labels Oct 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants