時代遅れだけど。
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