Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
16
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

Organization

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

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

  • 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 not register and get more from Qiita?
  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
16
Help us understand the problem. What are the problem?