Created
January 29, 2018 10:18
-
-
Save tmasjc/aee2f494c200f86089ce16b6da6fdf15 to your computer and use it in GitHub Desktop.
Simple shortcut to replace common AWS commands.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function _awsSwitchProfile() { | |
# Check if argument exists | |
if [ -z $1 ]; then echo "Usage: _awsSwitchProfile <profilename>"; return; fi | |
# Check if profile exists | |
exists="$(aws configure get aws_access_key_id --profile $1)" | |
# Switch profile | |
if [[ -n $exists ]]; then | |
export AWS_DEFAULT_PROFILE=$1; | |
export AWS_PROFILE=$1; | |
export AWS_REGION=$(aws configure get region --profile $1); | |
echo "Switched to AWS Profile: $1"; | |
fi | |
}; | |
# Print Instance ID | |
function _awsDescribeIp() { | |
aws ec2 describe-instances \ | |
--query 'Reservations[*].Instances[*].{Id:InstanceId,Img:ImageId,Ip:PublicIpAddress}' \ | |
--output text \ | |
--profile ${1:-default} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment