GCP Instance Schedules are objects that are created in GCP and used to manage when VMs can be turned on and off. VMs that are turned off cost very little so this is a nice way to reduce spend.

  • Schedule resources must exist in the same region as the VM that they will be attached to.

Create a Schedule

gcloud compute resource-policies create instance-schedule SCHEDULE_NAME \
   [--description='SCHEDULE_DESCRIPTION'] \
    [--region=REGION] \
    [--vm-start-schedule='START-OPERATION_SCHEDULE'] \
    [--vm-stop-schedule='STOP-OPERATION_SCHEDULE'] \
    [--timezone=TIME_ZONE] \
    [--initiation-date=INITIATION_DATE] \
    [--end-date=END_DATE]

Specify at least one of the following:

  • START-OPERATION_SCHEDULE: a schedule that describes when the attached VM instances are started, formatted as a cron expression. If you need VM instances to start at a specific time, schedule the operation 15 minutes earlier than needed. For more information, see start-operation schedule.
  • STOP-OPERATION_SCHEDULE: a schedule that describes when the attached VM instances are stopped, formatted as a cron expression. If you need VM instances to stop at a specific time, schedule the operation 15 minutes earlier than needed. For more information, see stop-operation schedule.

Attach or Remove Policy to a VM

gcloud compute instances add-resource-policies/remove-resource-policies VM_NAME \
    --resource-policies=SCHEDULE_NAME \
    [--zone=ZONE]

Resources