Skip to content

Instantly share code, notes, and snippets.

@ckrough
Last active December 18, 2015 13:59
Show Gist options
  • Save ckrough/5793755 to your computer and use it in GitHub Desktop.
Save ckrough/5793755 to your computer and use it in GitHub Desktop.
Simple AWS Command Line tool environment setup script
# AWS environments root
AWS_ENV_ROOT="${HOME}/.aws"
# Make sure we got a valid environment variable
#
if [[ -z "${1}" ]] || [[ ! -d "${AWS_ENV_ROOT}/${1}/" ]]; then
echo "No environment name specified or the environment directory is missing."
echo
echo "Usage:"
echo "setup-aws-env.sh <environment>"
echo
return
fi
# AWS Command Line tool environment variables
#
export JAVA_HOME="$(/usr/libexec/java_home)"
export EC2_HOME="/usr/local/Library/LinkedKegs/ec2-api-tools/jars"
export AWS_AUTO_SCALING_HOME="/usr/local/Library/LinkedKegs/auto-scaling/jars"
export AWS_IAM_HOME="/usr/local/Library/LinkedKegs/aws-iam-tools/jars"
export AWS_CLOUDWATCH_HOME="/usr/local/Library/LinkedKegs/cloud-watch/jars"
export SERVICE_HOME="$AWS_CLOUDWATCH_HOME"
export AWS_ELB_HOME="/usr/local/Library/LinkedKegs/elb-tools/jars"
export AWS_CLOUDFORMATION_HOME="/usr/local/Library/LinkedKegs/aws-cfn-tools/jars"
export PATH="${PATH}:${EC2_HOME}/bin:${AWS_AUTO_SCALING_HOME}/bin:${AWS_IAM_HOME}/bin:${AWS_CLOUDWATCH_HOME}/bin:${AWS_ELB_HOME}/bin:${AWS_CLOUDFORMATION_HOME}/bin"
# User Identification
#
export AWS_ENVIRONMENT=${1}
export AWS_CREDENTIAL_FILE=${AWS_ENV_ROOT}/${AWS_ENVIRONMENT}/aws_credentials.txt
export AWS_ACCESS_KEY=$( awk -F= '/AWS_ACCESS_KEY/ {print $2}' ${AWS_CREDENTIAL_FILE} )
export AWS_SECRET_KEY=$( awk -F= '/AWS_SECRET_KEY/ {print $2}' ${AWS_CREDENTIAL_FILE} )
export AWSAccessKeyId=$( awk -F= '/AWSAccessKeyId/ {print $2}' ${AWS_CREDENTIAL_FILE} )
export AWSSecretKey=$( awk -F= '/AWSSecretKey/ {print $2}' ${AWS_CREDENTIAL_FILE} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment