Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A remove command for AWS resources

License

NotificationsYou must be signed in to change notification settings

jckuester/awsrm

Repository files navigation

A remove command for AWS resources

ReleaseSoftware LicenseTravis

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.

Example

Delete resources by tags (or other attributes)

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:

  1. List resources viaawsls with the attributes you want to filter on(here:-a tags)
  2. Use standard tools likegrep to filter resources
  3. Pipe result toawsrm (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.

Delete across multiple accounts and regions

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 by IDs

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

  1. List resources viaawsls to find out what resources to delete.
  2. Useawsrm to delete the resources by resource type and ID(s)

Usage

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.

Installation

Binary Releases

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

Homebrew users can install by:

brew install jckuester/tap/awsrm

For more information on Homebrew taps please see thetap documentation.

Supported resources

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.

Disclaimer

You are using this tool at your own risk! I will not take responsibility if you delete any critical resources in yourproduction environments.


[8]ページ先頭

©2009-2025 Movatter.jp