#!/usr/bin/env bash # # AWS ENV vars for your project (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) # # AWS_PROFILE – Specifies the name of the CLI profile with the credentials and options to use. # This can be the name of a profile stored in a credentials (~/.aws/credentials) or config (~/.aws/config) # file, or the value default to use the default profile. If you specify this environment variable, # it overrides the behavior # of using the profile named [default] in the configuration file. # # AWS_DEFAULT_REGION – Specifies the AWS Region to send the request to. # AWS_REGION="us-east-1" AWS_PROFILE="default" #==========================================# # LIST EC2 IN AWS WITH PUBLIC IP ADDRS # #==========================================# func_aws_ec2_public_ip(){ echo "==================================================================" echo "LIST AWS EC2 ID and IT's PUBLIC IP ADDR" echo "==================================================================" aws ec2 describe-instances --output table \ --query 'Reservations[].Instances[].[InstanceId,PublicIpAddress,State.Name,Tags[?Key==`Name`] | [0].Value]' \ --profile ${AWS_PROFILE} --region ${AWS_REGION} echo "" } # main func_aws_ec2_public_ip