Reputation: 67
I have an instance running with access scope 'Set Access for each API', and explicitly allowing Compute Engine API with Read-Write access as showing in this below image.
So I logged inside the instance via SSH, and I tried to run this command:-
gcloud compute instances list
and I got an error:
- Required 'compute.zones.list' permission for 'projects/dotted-hxxl-xxx'
My user is having explicitly allowing access to compute Engine API but still I am getting the error. I shouldn't get this error right? What am I missing here?
Upvotes: 1
Views: 1553
Reputation: 8056
gcloud compute instances stop instance-1 --zone us-central1-c
gcloud compute instances describe instance-1 --zone us-central1-c | grep email
roles/compute.instanceAdmin
to the service accountgcloud projects add-iam-policy-binding your_project -- member="serviceAccount:SERVICE_ACCOUNT_ID@your_project.iam.gserviceaccount.com" --role="roles/compute.instanceAdmin"
gcloud compute instances start instance-1 --zone us-central1-c
gcloud compute ssh instance-1 --zone us-central1-c
gcloud compute instances list
Also read about the difference between IAM roles and OAuth scopes
When you set up an instance to run as a service account, you determine the level of access the service account has by the IAM roles that you grant to the service account. If the service account has no IAM roles, then no API methods can be run by the service account on that instance.
Furthermore, an instance's access scopes determine the default OAuth scopes for requests made through the gcloud tool and client libraries on the instance. As a result, access scopes potentially further limit access to API methods when authenticating through OAuth
Upvotes: 0
Reputation: 75715
when you are logged into an instance, the permissions that you get aren't these of your users but these of the compute engine provided by the metadata server.
Upvotes: 0