- Notifications
You must be signed in to change notification settings - Fork5
A remove command for AWS resources
License
jckuester/awsrm
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A remove command for AWS resources
This command line tool followstheUnix Philosophyofdoing only one thing and doing it well
:
It simplifies deleting over250 AWS resource types across multiple accounts and regions.
Like other Unix-like tools,awsrm
reveals its full power when combining it via pipes with other tools, suchasawsls
for listing AWS resources andgrep
for filtering by resourceattributes.
To delete, for example, all EC2 instances with tagName=foo
, run
awsls instance -a tags | grep Name=foo | awsrm
To filter on multiple attributes, display them withawsls
via the-a (--attributes) <comma-separated list>
flag.Every attribute in the Terraform documentation(here arethe attributes foraws_instance
) can be used:
- List resources via
awsls
with the attributes you want to filter on(here:-a tags
) - Use standard tools like
grep
to filter resources - Pipe result to
awsrm
(nothing is deleted until you confirm)
Note:awsls
output passes on profile and region information, so thatawsrm
knows for each resource in whataccount and region to delete it.
Depending on the type of resource, deletion can take some time. This GIF runs faster than EC2 instances are actuallyterminated; the shell prompt shows the real execution times in seconds.
List all instances withawsls
in the AWS accounts associated with profilemyaccount1
andmyaccount2
in bothregionsus-west-2
andus-east-1
and pipe the result toawsrm
:
awsls -p myaccount1,myaccount2 -r us-west-2,us-east-1 instance | awsrm
Delete specific resources by ID, for example, some IAM roles
awsrm iam_role db-cluster elb nginx
or VPCs
awsrm vpc vpc-1234 vpc-3456 vpc-7689
- List resources via
awsls
to find out what resources to delete. - Use
awsrm
to delete the resources by resource type and ID(s)
Input via arguments:
awsrm [flags] <resource_type> <id> [<id>...]
Input via pipe:
awsls [flags] <resource_type> | awsrm
or
echo "<resource_type> <id> <profile> <region>" | awsrm
To see options available runawsrm --help
.
You can download a specific version on thereleases page or use thefollowing way to install to./bin/
:
curl -sSfL https://raw.githubusercontent.com/jckuester/awsrm/master/install.sh| sh -s v0.2.0
Homebrew users can install by:
brew install jckuester/tap/awsrm
For more information on Homebrew taps please see thetap documentation.
This tool can not only delete any resource type thatissupported by awsls, but any resourcetypecovered by the Terraform AWS Provider.
Note: the prefixaws_
for resource types is optional. This means, for example,awsrm aws_instance <id>
andawsrm instance <id>
are both valid commands.
You are using this tool at your own risk! I will not take responsibility if you delete any critical resources in yourproduction environments.
About
A remove command for AWS resources