You need to install AWS CLI package in your machine, there are a number of different ways to install the AWS CLI, depending on your operating system,
The below steps are common to install,
Download the awscli-bundle file with .zip format and extract
step 1:
$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
step2:
$ unzip awscli-bundle.zip
Have a install script file in your awscli-bundle directory,
step3:
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
If you want to know the awscli help,
step4:
$ ./awscli-bundle/install -h
To use this below example, type "aws configure" at the command line and press Enter. Enter each of your access keys in turn and press Enter. Then, enter a region name in the format shown, press Enter, and press Enter a final time to skip the output format setting.
step 5:
$ aws configure
AWS Access Key ID [None]: SDFKSOFWI27EXAMPLE
AWS Secret Access Key [None]: SDSddfrXURnFFSMIGK7MDEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: ENTER
Get All Private IP address from each instances:
$ aws ec2 describe-instances --filter Name=tag:Name,Values=MACHINENAME* | grep "PrivateIpAddress" |grep -o -P "\d+\.\d+\.\d+\.\d+" | grep -v '^10\.' | sort | uniq
Get single Private IP address from each instances:
$ aws ec2 describe-instances --filters Name=tag:Name,Values=MACHINENAME* --query 'Reservations[].Instances[].[PrivateIpAddress]' --output text | sort | uniq
Comments (0)