1
votes

Hey I'm trying to create new users in IAM on GCP and automate it with terraform, I know you can do so on AWS with the aws_iam_user is there an equivalent on GCP ? I see the google_project_iam_member but it doesn't create a new user but expects one to be there already.

PS error message looks like this

Error: Request "Create IAM Members roles/storage.objectViewer 
user:tom@example.com for \"project \\\"<my-project-id>\\\"\"" returned 
error: Error applying IAM policy for project "<my-project-id>": Error 
setting IAM policy for project "<my-project-id>": googleapi: Error 400: 
User tom@example.com does not exist., badRequest

and the code is simply

provider "google" {
  credentials = file(var.credentials)
  project = var.project_name
  region  = var.region
}

resource "google_project_iam_member" "member" {
  project = var.project_id
  role    = "roles/storage.objectViewer"
  member  = "user:tom@example.com"
}
1
I believe the user is just any email with an associated google account. You can make service accounts programatically, but I expect a google account for a person would requite a captcha or similar.Hitobat
hmmm that makes sense I'll try making dummy gmail account and adding itpotatopotato
Oh my god, you're a geniuspotatopotato

1 Answers

1
votes

Well this is awkward or maybe not and just my mis-interpretation. You don't really create user - the user is just an Google account user - with it's own password, associated phone etc. - you cannot create new user on gcp (google) - you can merely allow existing user to have some role on your GCP project/organization.

PS: kudos to @Hitobat for suggestion