Skip to content

Commit ce7fe16

Browse files
author
Jason Schmidt
authored
feat: update creds script for permanent creds (#143)
* feat: update creds script for permanent creds * fix: better info message for unset token var
1 parent cf5b394 commit ce7fe16

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

bin/aws_write_creds.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/usr/bin/env bash
2-
set -x
3-
set -v
4-
52
set -o errexit # abort on nonzero exit status
6-
set -o nounset # abort on unbound variable
73
set -o pipefail # don't hide errors within pipes
84

95
#
@@ -25,16 +21,21 @@ if [ ${#missing_auth_vars[@]} -ne 0 ]
2521
then
2622
echo "Did not find values for:"
2723
printf ' %q\n' "${missing_vars[@]}"
28-
echo "Will assume they are in credentials file"
24+
echo "Will assume they are in credentials file or not needed"
2925
else
3026
echo "Creating credentials file"
3127
# Create the directory....
3228
mkdir -p ~/.aws
3329
CREDS=~/.aws/credentials
3430
echo "[default]" > $CREDS
3531
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> $CREDS
36-
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> $CREDS
37-
echo "aws_session_token=$AWS_SESSION_TOKEN" >> $CREDS
32+
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> $CREDS
33+
# This is if we have non-temp credentials...
34+
if [[ -z "${AWS_SESSION_TOKEN+x}" ]]; then
35+
echo "Variable AWS_SESSION_TOKEN was unset; not adding to credentials"
36+
else
37+
echo "aws_session_token=$AWS_SESSION_TOKEN" >> $CREDS
38+
fi
3839

3940
fi
4041

0 commit comments

Comments
 (0)