Skip to content

Instantly share code, notes, and snippets.

@okisanjp
Last active March 6, 2017 14:24
Show Gist options
  • Save okisanjp/158bc0498f751259ecd1 to your computer and use it in GitHub Desktop.
Save okisanjp/158bc0498f751259ecd1 to your computer and use it in GitHub Desktop.
awscli + jqで開発マシンの/etc/hosts用出力
### プライベートIPの場合
$ aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | .PrivateIpAddress + "\t" + .Tags[].Value'
192.0.2.1 aws1.example
192.0.2.2 aws2.example
192.0.2.3 aws3.example
192.0.2.4 aws4.example
192.0.2.5 aws5.example
192.0.2.6 aws6.example
192.0.2.7 aws7.example
192.0.2.8 aws8.example
### パブリックIPの場合
$ aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | .PublicIpAddress + "\t" + .Tags[].Value'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment