Mirror of static site repo git.pfy.ch/pfych/static
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253#!/usr/bin/env bash
shopt -s failglobset -eu -o pipefail
echo "Begin: Setup AWS"
echo "Exporting env vars"export AWS_PROFILE="${AWS_PROFILE:-"dev"}"echo "Profile: [$AWS_PROFILE]"
export AWS_REGION="${AWS_REGION:-"ap-southeast-2"}"echo "Region: [$AWS_REGION]"
export AWS_HOME="/usr/local/bin/aws"export PATH="${AWS_HOME:-}:$PATH"
if [ "$AWS_ACCESS_KEY_ID" == "" ] || [ "$AWS_SECRET_ACCESS_KEY" == "" ]; then # These can be used if master and prod are in different accounts or the IAM roles have different access if [ "$BITBUCKET_BRANCH" == "prod" ]; then export AWS_ACCESS_KEY_ID="${PROD_AWS_ACCOUNT_ACCESS_KEY_ID}" export AWS_SECRET_ACCESS_KEY="${PROD_AWS_ACCOUNT_SECRET_ACCESS_KEY}" else export AWS_ACCESS_KEY_ID="${NON_AWS_ACCOUNT_ACCESS_KEY_ID}" export AWS_SECRET_ACCESS_KEY="${NON_AWS_ACCOUNT_SECRET_ACCESS_KEY}" fifi
if [ "$AWS_ACCESS_KEY_ID" == "" ] || [ "$AWS_SECRET_ACCESS_KEY" == "" ]; then echo "Warning: No AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY provided." echo "You will not be able to deploy some of the AWS components of the environment."fi
aws --versionaws configure set cli_follow_urlparam falseaws configure set region "${AWS_REGION:-}"
if ! aws configure list-profiles | grep -cq "${AWS_PROFILE}" ; then echo "[profile $AWS_PROFILE]" >>~/.aws/config echo "region=${AWS_REGION:-}" >>~/.aws/configelse echo "Profile exists"fi
# by setting AWS_PROFILE, the following functions relate to itaws configure set aws_access_key_id "${AWS_ACCESS_KEY_ID:-}"aws configure set aws_secret_access_key "${AWS_SECRET_ACCESS_KEY:-}"
echo "Current user:"aws iam get-user
echo "Finish: Setup AWS"