go-lambda-cleanup

A Golang based CLI for removing unused versions of AWS Lambdas.
Installation
go-lambda-cleanup is distributed as a single binary. Download the binary and install go-lambda-cleanup by unzipping the zip file and and moving the included binary to a directory in your system's PATH. /usr/local/bin is the recommended path for UNIX/LINUX environments.
wget https://github.com/karl-cardenas-coding/go-lambda-cleanup/releases/download/v1.0.0/go-lambda-cleanup_linux_amd64.zip
unzip go-lambda-cleanup_linux_amd64.zip
sudo mv go-clean-lambda /usr/local/bin/
Usage
Usage:
glc clean [flags]
Flags:
-c, --count int8 The number of versions to retain from $LATEST-(n) (default 1)
-h, --help help for clean
Global Flags:
-s, --enableSharedCredentials Leverages the default ~/.aws/credentials file (bool)
-p, --profile string Specify the AWS profile to leverage for authentication.
-r, --region string Specify the desired AWS region to target.
-v, --verbose Set to true to enable debugging (bool)
Use "gcl [command] --help" for more information about a command.
To retain 2 version excluding $LATEST
glc clean -r us-east-2 -c 2 -s true -p myProfile
Authentication
go-lambda-clean utilizes the default AWS Go SDK credentials provider to find AWS credentials. The default provider chain looks for credentials in the following order:
-
Environment variables.
-
Shared credentials file.
-
If your application uses an ECS task definition or RunTask API operation, IAM role for tasks.
-
If your application is running on an Amazon EC2 instance, IAM role for Amazon EC2.
Shared File Example
If ~/.aws/config and ~/.aws/config is setup for the AWS CLI then you may leverage the existing profile confugrations for authentication.
$ export AWS_PROFILE=sb-test
$ glc clean -r us-west-2 -s true
INFO[03/05/21] Scanning AWS environment in us-west-2
INFO[03/05/21] ............
Alternatively, the --profile flag may be used.
$ glc clean -r us-west-2 -s true -p myProfile
INFO[03/05/21] Scanning AWS environment in us-west-2
INFO[03/05/21] ............
Environment Variables
Static credentials may be utlized to authenticate into AWS.
$ export AWS_ACCESS_KEY_ID=YOUR_AKID
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
$ export AWS_SESSION_TOKEN=TOKEN
$ gcl clean -r us-west-2
2021/03/04 20:42:46 Scanning AWS environment in us-west-2.....
2021/03/04 20:42:46 ............
Contributing to go-lambda-cleanup
For a complete guide to contributing to go-lambda-clean, see the Contribution Guide.
Contributions to go-lambda-cleanup of any kind including documentation, organization, tutorials, blog posts, bug reports, issues, feature requests, feature implementations, pull requests, answering questions on the forum, helping to manage issues, etc.
Helpful Links
AWS Credentials Configuration
Golang Cobra CLI Framework
AWS Go SDK Credentials