I'm trying to enable os login for an instance. I've already set the Metadata os-login: TRUE
and added my public key to my account with the gcloud compute os-login ssh-keys add
command. Now, I'm trying to add my role to the instance, as described here: https://cloud.google.com/compute/docs/instances/managing-instance-access#configure_users
I'm running into an issue with the command however and the error message doesn't make it clear to me what's going wrong. Here's my command and the output:
$ gcloud beta compute instances add-iam-policy-binding tim-test --project='my-project' --zone='europe-west4-a' --member='user:[email protected]' --role=roles/compute.osAdminLogin
ERROR: (gcloud.beta.compute.instances.add-iam-policy-binding) HTTPError 400: Invalid value 'projects/packer-automation/zones/europe-west4-a/instances/tim-test'. Values must match the following regular expression: '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?|[1-9][0-9]{0,19}'
What am I doing wrong?
If you already did the OS login setup correctly, there is no need to add the compute instance information in the command:
gcloud beta compute instances ....
Maybe that information you are checking is not that detailed, try using a command like this:
gcloud projects add-iam-policy-binding example-project-id-1 \ --member='user:[email protected]' --role='roles/editor'
Here you can find more details or you can also use beta commands