A simple Elixir script to notify of a GCE spot instance preemption event via Telegram bot API token.
The mix escript.build output is used as a standalone shutdown script to be
applied to a Compute Engine instance's shutdown-script metadata. This is not
intended to be used as a normal Elixir package.
The script makes the following assumptions:
-
The secrets
TG_TOKENandTG_TARGET_IDexist in the file/run/secrets/tg/nixiumbot. You will very likely need to redefine@secrets_pathinlib/telecry/cli.ex. -
The format for the secrets file is:
TG_TOKEN=your-tg-token-here
TG_TARGET_ID=target-id-to-send-message-to
- The resulting script output from
MIX_ENV=prod mix escript.buildis going to be larger than Google's allowed local limit of 256KB, so you will need to either copy the script to the server manually and target it's local path directly (e.g.,metadata.shutdown-script = #! /path/to/escript /path/to/telecry)
Alternatively, you should be able to copy it to a bucket and use
metadata.shutdown-script-url.