Last active
October 13, 2024 17:35
-
-
Save ethanmdavidson/af0c2cacd4c712a13961cf9bab8785ae to your computer and use it in GitHub Desktop.
Packer Configuration for GCP spot/preemptible instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source googlecompute preemptible-builder { | |
project_id = "<PROJECT_ID>" | |
zone = "us-west4-b" # using us-west4 because they have much cheaper spot prices right now. | |
ssh_username = "packer" | |
source_image = "debian-11-bullseye-v20230306" | |
wrap_startup_script = false | |
disk_size = 10 | |
preemptible = true | |
metadata = { | |
#if instance gets preempted, send SIGINT to packer (prevents packer from hanging for 20m trying to reconnect) | |
#To see if it was really preempted, run gcloud compute operations list --filter="operationType=compute.instances.preempted" | |
"shutdown-script" : "for pid in $(pgrep -U packer ssh); do sudo kill -2 $pid; done" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment