0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

指定したEC2インスタンスのEIPを開放するスクリプ

Last updated at Posted at 2020-09-07

時代遅れだけど。

cat <<EOD | xargs aws ec2 describe-instances --instance-ids \
| jq '.Reservations[].Instances[] | select(has("PublicIpAddress")) | .PublicIpAddress' -r \
| tee \
>(xargs -I{} aws ec2 disassociate-address --public-ip {}) \
>(xargs -I{} aws ec2 describe-addresses --filter Name=public-ip,Values={} | jq '.Addresses[].AllocationId' -r | xargs -I{} aws ec2 release-address --allocation-id {})
i-xxxxxxxxxxxxxxxxx
i-xxxxxxxxxxxxxxxxx
i-xxxxxxxxxxxxxxxxx
i-xxxxxxxxxxxxxxxxx
i-xxxxxxxxxxxxxxxxx
i-xxxxxxxxxxxxxxxxx
i-xxxxxxxxxxxxxxxxx
(好きなだけ改行区切りでどうぞ)
EOD
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?