using instance metadata (source : AWS Docs)
- Connect to your instance.
- Use the following command to get its private IP address:
curl http://169.254.169.254/latest/meta-data/local-ipv4
- Use the following command to get its public IP address:
curl http://169.254.169.254/latest/meta-data/public-ipv4