Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Created August 15, 2017 04:30
Show Gist options
  • Save shiumachi/d2312285539968521bb154bcbb7f0568 to your computer and use it in GitHub Desktop.
Save shiumachi/d2312285539968521bb154bcbb7f0568 to your computer and use it in GitHub Desktop.
AWS上の特定のインスタンスのホスト名とIPアドレスを取得する
PROFILE=your_profile
INSTANCE_NAME=your_instance_name
aws --profile ${PROFILE} ec2 describe-instances | jq -r ".Reservations[] | select(.Instances[0].Tags[].Value == \"${INSTANCE_NAME}\") | .Instances[0] | {PrivateDnsName: .PrivateDnsName, PrivateIpAddress: .PrivateIpAddress, PublicDnsName: .PublicDnsName, PublicIpAddress: .PublicIpAddress}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment