GithubHelp home page GithubHelp logo

isabella232 / gcp-hashicorp-packer-reaper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from binxio/gcp-hashicorp-packer-reaper

0.0 0.0 0.0 94 KB

stop or terminate dangling packer instances on GCP

License: Apache License 2.0

Shell 11.80% Python 57.05% Makefile 16.70% HCL 13.72% Dockerfile 0.72%

gcp-hashicorp-packer-reaper's Introduction

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.

gcp-hashicorp-packer-reaper's People

Contributors

dependabot[bot] avatar mvanholsteijn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.