diff --git a/home/.bashrc.d/topics/tool-config.sh b/home/.bashrc.d/topics/tool-config.sh index 187d73e..5df071d 100644 --- a/home/.bashrc.d/topics/tool-config.sh +++ b/home/.bashrc.d/topics/tool-config.sh @@ -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") \ diff --git a/home/bin/aws-mfa-gen b/home/bin/aws-mfa-gen index 67dc709..3e254b8 100755 --- a/home/bin/aws-mfa-gen +++ b/home/bin/aws-mfa-gen @@ -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"