Skip to content

tom-uchida/auto-stop-gce-instances

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

auto-stop-gce-instances

Architecture

How to deploy

1. Deploy Pub/Sub

$ gcloud pubsub topics create $PUBSUB_NAME

2. Deploy Cloud Functions

$ gcloud functions deploy $FUNCTIONS_NAME \
    --runtime go113 \
    --trigger-topic $PUBSUB_NAME \
    --region asia-northeast1 \
    --set-env-vars GCP_PROJECT=$GCP_PROJECT

3. Deploy Cloud Scheduler

$ gcloud scheduler jobs create pubsub $SCHEDULER_NAME \
    --time-zone "Asia/Tokyo" \
    --schedule "0 21 * * 1-5" \
    --topic $PUBSUB_NAME \
    --message-body '{"labelKey":"is-auto-stop", "labelValue":"true"}' \
    --description "Automatically stop gce instances"

References