google-cloud-platformgoogle-compute-enginegoogle-iamgoogle-cloud-iam

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 service-5424xxxxxxx@compute-system.iam.gserviceaccount.com needs to have [compute.instances.start,compute.instances.stop] permissions applied in order to perform this operation.

enter image description here


Solution

  • The problem is that the service service-5424xxxxxxx@compute-system.iam.gserviceaccount.com does not have a role that contains the permissions compute.instances.start and compute.instances.stop.

    The following roles contain that permission:

    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:service-5424xxxxxxx@compute-system.iam.gserviceaccount.com" \
    --role "roles/compute.instanceAdmin.v1"
    

    Of course, use the correct service account email address.