Search code examples
google-cloud-platformterraformterraform-provider-gcp

Error retrieving IAM policy GCP when terraform plan?


Hello one of my modules for terraform bootstrap for GCP contains

  resource "google_organization_iam_member" "organizationAdmin" {
  for_each = toset(var.users)
  org_id   = var.organization_id
  role     = "roles/resourcemanager.organizationAdmin"
  member   = each.value

}

right now I'm getting

Error: Error retrieving IAM policy for organization "903021035085 ": googleapi: Error 400: Request contains an invalid argument., badRequest
│ 
│   with module.bootstrap_permissions.google_organization_iam_member.organizationAdmin["group:[email protected]"],
│   on ../modules/bootstrap_permissions/main.tf line 1, in resource "google_organization_iam_member" "organizationAdmin":
│    1: resource "google_organization_iam_member" "organizationAdmin" {

The account making the request has Owner permission at the Organization level, is there a reason why I am getting an error, when I do terraform plan.


Solution

  • The value of var.organization_id has a trailing space (see the error message), e.g., "123 " instead of "123". Remove this space and it should work.