Skip to content

Instantly share code, notes, and snippets.

@ajorpheus
Forked from mjul/aws_env
Created January 12, 2023 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajorpheus/cb3ebee1c68dbc50990bc27c58bfc8a8 to your computer and use it in GitHub Desktop.
Save ajorpheus/cb3ebee1c68dbc50990bc27c58bfc8a8 to your computer and use it in GitHub Desktop.
Get environment variables from AWS profile (for use with docker-machine)
#!/bin/sh
# Set the AWS environment variables for an AWS profile
# Useful for docker-machine
#
# Example:
#
# aws_env profile-for-testing
#
# Further information:
# See the AWS CLI `aws configure`
#
echo "# Environment for AWS profile '$1'"
echo export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id --profile $1)
echo export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key --profile $1)
echo export AWS_DEFAULT_REGION=$(aws configure get region --profile $1)
echo "# Run this command to configure your shell:"
echo "# eval \$($0 ${@})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment