awsclean [command] [flags]
awsclean uses already provided credentials in ~/.aws/credentials also it uses the central configuration in ~/.aws/config!
awsclean ami
scan all AMIs owned by self and delete them if they are unused and older then 7 days.
awsclean ami --account 2451251
scan all AMIs of self and were AWS account 2451251 are owner
awsclean ami --dry-run
do not delete anything just show what you would do
awsclean ami --older-then 5w
delete all images which are older then 5w and are unused
awsclean ami --ignore ^amia.* --ignore ^amib.*
delete all images which name does not start with amia or amib
awsclean ami --launch-templates
additionally scan launch templates for used AMIs
awsclean ebs --older-then 5w
delete all EBS volumes which are older then 5w and are not bound
awsclean ebs --dry-run
do not delete any EBS volume just show what you would do
- 1st
-
all used AMIs are filtered out
- 2nd
-
all ignore patterns are matched an ignored AMIs are filtered out
- 3rd
-
the age of the AMI is checked if it’s younger then the given duration the AMI is filtered out
- -a, --account string
-
Set AWS account number to cleanup AMIs. Used to set owner information when selecting AMIs. If not set only 'self' is used.
- -d, --dry-run
-
If set to true nothing will be deleted. And amiclean will just show what it would do!
- -o, --older-then string
-
Set the duration string (e.g 5d, 1w etc.) how old AMIs must be to be deleted. E.g. if set to 7d, AMIs will be delete which are older then 7 days. (default "7d")
- -i, --ignore stringArray
-
Set ignore regex patterns. If a ami name matches the pattern it will be exclueded from cleanup.
- -l, --launch-templates
-
Additionally scan launch templates for used AMIs.
- -?, --help
-
Print usage information
- -v, --version
-
Print version information
In order to test the ec2client I used mockery to create the mocks:
go generate ./...
The mockery configuration is done in:
link:.mockery.yaml[role=include]