- Create a user for AWS from IAMUSER
- Save your
AWS Access Key ID
andAWS Secret Access Key
for you IAMUSER. - ssh into AWS EC2 and add the below to your ~/.bash_profile of ec2_user.
- As per AWS docs You must specify an AWS Region when using the AWS CLI, either explicitly or by setting a default Region. For a list of the available Regions, see Regions and Endpoints.
export REGION=ap-south-1
export AWS_INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
export EC2_NAME=$(aws ec2 describe-tags --region $REGION --filters "Name=resource-id,Values=$AWS_INSTANCE_ID" "Name=key,Values=Name" --output text | cut -f5)
- Reload the bash profile with
source ~/.bash_profile