ZeroKnowledge
ZeroKnowledge

Reputation: 31

GCP VM Auto Stop and Start setup using GCP Instance schedule

I'm trying to setup an auto stop/start of some of my VMs in GCP and I already have an VM admin permission but when adding a VM to a instance schedule created I'm getting below error:

Compute Engine System service account [email protected] needs to have [compute.instances.start,compute.instances.stop] permissions applied in order to perform this operation.

enter image description here

Upvotes: 1

Views: 5851

Answers (2)

Nishant
Nishant

Reputation: 435

For those reading this and wondering why this is not working when they have given Cloud Scheduler Admin /Compute Admin/Compute Instance Admin (beta)/Compute Instance Admin (v1) to the user through Google Cloud IAM, it is because you have to give these priveleges to [email protected], where as you have given these privileges to [email protected]. The "service-" at the beginning matters.

To achieve this, refer to @John-Hanley 's answer above

Upvotes: 1

John Hanley
John Hanley

Reputation: 81462

The problem is that the service [email protected] does not have a role that contains the permissions compute.instances.start and compute.instances.stop.

The following roles contain that permission:

  • Compute Instance Admin - roles/compute.instanceAdmin
  • Compute Instance Admin (v1) - roles/compute.instanceAdmin.v1

Use the Google Cloud Console GUI to add the desired role or use the CLI:

gcloud projects add-iam-policy-binding REPLACE_WITH_PROECT_ID \
--member "serviceAccount:[email protected]" \
--role "roles/compute.instanceAdmin.v1"

Of course, use the correct service account email address.

Upvotes: 15

Related Questions