Skip to main content

reap dangling packer builder machines on GCP

Project description

AWS Hashicorp Packer Reaper

Hashicorp Packer is a great tool for building Google Compute Engine Images. However, sometimes the virtual machine running packer is not stopped. This utility stops or terminated all virtual machines with the name tag 'Packer Builder'

You can use it as a command line utility or install it as an Cloud Run service and stop the spend , NoOps style!

install the packer reaper

to install the packer reaper, type:

pip install gcp-hashicorp-packer-reaper

show running packer instances

To show running packer instances:

$ gcp-hashicorp-packer-reaper list
packer-5e99d4f2-b5a5-e9e0-b763-cd5102ae7e73 launched 7 minutes ago in your-project - europe-west4-c - RUNNING
INFO: 1 packer builder instances found

stop running packer instances

To stop running packer instances older than 2 hours:

$ gcp-hashicorp-packer-reaper stop --older-than 2h

INFO: stopping packer-5e99d4f2-b5a5-e9e0-b763-cd5102ae7e73 in your-project created 3 hours ago
INFO: total of 1 running instances stopped

delete running packer instances

To terminate stopped and running packer instances older than 24 hours:

gcp-hashicorp-packer-reaper --verbose delete --older-than 24h

INFO: deleting packer-5e99d4f2-b5a5-e9e0-b763-cd5102ae7e73 in your-project created 2 days ago
INFO: total of 1 instances deleted

deploy the packer reaper

To deploy the packer reaper as a service in your project, type:

git clone https://github.com/binxio/gcp-hashicorp-packer-reaper.git
cd gcp-hashicorp-packer-reaper

PROJECT=$(gcloud config get-value project)
make USERNAME=$PROJECT snapshot

cd terraform
terraform init
terraform apply -var project=$PROJECT -auto-approve

This will install the packer reaper in your GCP project and run every 10 minutes, and delete instances older than 2 hours. You can change the schedule and the action to meet your requirements.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcp-hashicorp-packer-reaper-0.1.3.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file gcp-hashicorp-packer-reaper-0.1.3.tar.gz.

File metadata

  • Download URL: gcp-hashicorp-packer-reaper-0.1.3.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for gcp-hashicorp-packer-reaper-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0c4514538f2590ddb053c35c4cdcafb9eaeba210649dfab7490b7c8f4382f249
MD5 d00c97704b20b80fc3006e2ab85606af
BLAKE2b-256 7ac4093ccceb76fcbfe51c9ff3ffff7f310dda4b1c36e67b5c29cf15f1dcbb3d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page