aws_public_ips is a tool to fetch all public IP addresses (both IPv4/IPv6) associated with an AWS account.
It can be used as a library and as a CLI, and supports the following AWS services (all with both Classic & VPC flavors):
- EC2 (and as a result: ECS, EKS, Beanstalk, Fargate, Batch, & NAT Instances)
- ELB (Classic ELB)
- ELBv2 (ALB/NLB)
If a service isn't listed (S3, ElastiCache, etc) it's most likely because it doesn't have anything to support (i.e. it might not be deployable publicly, it might have all ip addresses resolve to global AWS infrastructure, etc).
Install the gem and run it:
$ gem install aws_public_ips
# Uses default ~/.aws/credentials
# With a custom profile
$ AWS_PROFILE=production aws_public_ips
$ aws_public_ips --help
Usage: aws_public_ips [options]
-s, --services <s1>,<s2>,<s3> List of AWS services to check. Available services: apigateway,cloudfront,ec2,elasticsearch,elb,elbv2,lightsail,rds,redshift. Defaults to all.
-f, --format <format> Set output format. Available formats: json,prettyjson,text. Defaults to text.
-v, --[no-]verbose Enable debug/trace output
--version Print version
-h, --help Show this help message
For authentication aws_public_ips uses the default aws-sdk-ruby configuration, meaning that the following are checked in order:
- Environment variables:
- Shared credentials files:
- Instance profile via metadata endpoint (if running on EC2, ECS, EKS, or Fargate)
To find the public IPs from all AWS services, the minimal policy needed by your IAM user is:
Feel free to tweet or direct message: @arkadiyt