Skip to content

Commit

Permalink
Always enable AWS_SDK_LOAD_CONFIG var
Browse files Browse the repository at this point in the history
This appears to be an anti-feature of the AWS Golang SDK which breaks
profile support if not set

Related: hashicorp/terraform-provider-aws#233
  • Loading branch information
stormbeta committed Jun 26, 2019
1 parent 67acb2e commit 4f1637f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions home/.bashrc.d/topics/tool-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if [[ -n "${GOPATH}" ]]; then
add-path-if-exists "${GOPATH}/bin"
fi

# For some reason, the Go AWS SDK in particular refuses to load profiles and
# credentials correctly without this, which includes terraform
export AWS_SDK_LOAD_CONFIG=1

# Android SDK paths
(set-if-exists ANDROID_HOME "${HOME}/Library/Android/sdk" \
|| set-if-exists ANDROID_HOME "${HOME}/.android-sdk") \
Expand Down
3 changes: 3 additions & 0 deletions home/bin/aws-mfa-gen
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function generate-creds {
fi
read -r access_key_id secret_access_key session_token <<< "$sts_response"

# NOTE: if using any tools based on AWS's golang SDK, you'll need to set
# AWS_SDK_LOAD_CONFIG or they won't work properly with profiles

if [[ -n "$access_key_id" ]]; then
aws --profile "$MFA_PROFILE" configure set aws_access_key_id "$access_key_id"
aws --profile "$MFA_PROFILE" configure set aws_secret_access_key "$secret_access_key"
Expand Down

0 comments on commit 4f1637f

Please sign in to comment.