Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

packer_cleaner

This project provides tools for cleaning up Packer builds and related resources. It helps automate the process of removing unused or obsolete artifacts generated by Packer, streamlining infrastructure management.

Docker Image

The Docker image for this project was manually created using the following command:

docker build --push --platform linux/amd64,linux/arm64 -t cuotos/packer-cleaner .

This builds and pushes a multi-platform image (amd64 and arm64) to Docker Hub under the tag cuotos/packer-cleaner.

How It Works

The main script (code/index.py) automates the cleanup of AWS EC2 instances created by Packer. It:

  • Connects to AWS EC2 using boto3.
  • Searches for instances with:
    • Key name matching packer_*
    • Tag Name set to Packer Builder
    • State of stopped or running
  • Checks the launch time of each instance.
  • If an instance is older than the configured maximum age (default: 24 hours, set via the MAX_AGE environment variable), it is marked for action.
  • Depending on the METHOD environment variable:
    • stop: Stops the old instances
    • terminate: Terminates the old instances
    • Any other value: Only logs the instances without taking action

This helps ensure that obsolete Packer builder instances do not linger in your AWS account.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages