Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
shell environment setup script for cloudigrade
cd ~/projects/cloudigrade
[ -z $VIRTUAL_ENV ] || deactivate 2>&1 >/dev/null
workon cloudigrade
export DJANGO_SETTINGS_MODULE=config.settings.local
export AWS_PROFILE=cluster
unset \
AWS_ACCESS_KEY_ID \
AWS_SECRET_ACCESS_KEY \
AWS_DEFAULT_REGION \
AWS_SQS_ACCESS_KEY_ID \
AWS_SQS_SECRET_ACCESS_KEY \
AWS_SQS_REGION \
AWS_SQS_QUEUE_NAME_PREFIX \
AWS_SQS_URL \
QUEUE_CONNECTION_URL
read -r -d '' PYSCRIPT <<'EOF'
import boto3
session = boto3.Session()
credentials = session.get_credentials()
print(credentials.access_key, credentials.secret_key, session.region_name)
EOF
IFS=" " read AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION \
<<< $(echo "$PYSCRIPT" | python)
export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION
export AWS_SQS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
export AWS_SQS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
export AWS_SQS_REGION="${AWS_DEFAULT_REGION}"
export AWS_SQS_QUEUE_NAME_PREFIX="${USER}-"
read -r -d '' PYSCRIPT <<'EOF'
from os import environ
from urllib.parse import quote
print('sqs://{}:{}@'.format(
quote(environ['AWS_SQS_ACCESS_KEY_ID'], safe=''),
quote(environ['AWS_SQS_SECRET_ACCESS_KEY'], safe='')
))
EOF
export AWS_SQS_URL=$(echo "$PYSCRIPT" | python)
export QUEUE_CONNECTION_URL="$AWS_SQS_URL"
unset PYSCRIPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment