Skip to content

Commit

Permalink
only set profile with alias if alias is set
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalFrenz committed Jun 4, 2024
1 parent 9c0f5d6 commit 3dc3c94
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions aws_login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ function aws_login() {
fi

local temporary_rackspace_token=""
local rackspace_tennant_id
local rackspace_username
local rackspace_api_key
local aws_access_key_id
local aws_secret_access_key
local aws_session_token
local rackspace_tennant_id=""
local rackspace_username=""
local rackspace_api_key=""
local aws_access_key_id=""
local aws_secret_access_key=""
local aws_session_token=""

function read_input() {
if [ "${3:-}" = "hide_input" ]; then
Expand Down Expand Up @@ -252,9 +252,12 @@ function aws_login() {
aws configure --profile "$aws_profile_name" set aws_secret_access_key "$aws_secret_access_key"
aws configure --profile "$aws_profile_name" set aws_session_token "$aws_session_token"

aws configure --profile "$aws_profile_name_alias" set aws_access_key_id "$aws_access_key_id"
aws configure --profile "$aws_profile_name_alias" set aws_secret_access_key "$aws_secret_access_key"
aws configure --profile "$aws_profile_name_alias" set aws_session_token "$aws_session_token"
# only set alias config if alias is set
if [ -n "$aws_profile_name_alias" ]; then
aws configure --profile "$aws_profile_name_alias" set aws_access_key_id "$aws_access_key_id"
aws configure --profile "$aws_profile_name_alias" set aws_secret_access_key "$aws_secret_access_key"
aws configure --profile "$aws_profile_name_alias" set aws_session_token "$aws_session_token"
fi
else
echo "The AWS credentials are still valid."
fi
Expand Down

0 comments on commit 3dc3c94

Please sign in to comment.