Help us understand the problem. What is going on with this article?

AWSで全てのリージョンから無駄リソースを抽出するワンライナー

More than 3 years have passed since last update.

ありがちな消去忘れなどを防ぐため、たまに以下のスクリプトを動かしてきれいな状態にしておきましょう。

  • aws configure は済ませてある前提です。まだの方はaws configureで設定するか、環境変数に設定するかを済ませて下さい。 (2015/04/09 01:20 ELBに関する記述を変更しました)

EBS

for region in `aws ec2 describe-regions --query 'Regions[].RegionName' --output text`;do aws ec2 describe-volumes --region ${region} --filters Name=attachment.status,Values=detached;done

ElasticIP

for region in `aws ec2 describe-regions --query 'Regions[].RegionName' --output text`;do aws ec2 describe-addresses --region ${region} --query 'Addresses[?InstanceId==`null`]';done 

ELB

for region in `aws ec2 describe-regions --query 'Regions[].RegionName' --output text`;do aws elb describe-load-balancers --query 'LoadBalancerDescriptions[?length(Instances)==`0`].LoadBalancerName' --region ${region};done 

ENI

for region in `aws ec2 describe-regions --query 'Regions[].RegionName' --output text`;do aws ec2 describe-network-interfaces --filters Name=attachment.status,Values=detached --region ${region};done

参考

JMESpath
http://jmespath.readthedocs.org/en/latest/index.html

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away