Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Session Token support #629

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions images/builders/aws.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"instance_type": "{{ user `default_size` }}",
"region": "{{ user `region` }}",
"secret_key": "{{ user `aws_secret_access_key` }}",
"token": "{{ user `aws_session_token` }}",
"launch_block_device_mappings": [
{
"device_name": "/dev/sda1",
Expand Down
11 changes: 10 additions & 1 deletion interact/account-helpers/aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@ while [[ "$SECRET_KEY" == "" ]]; do
read SECRET_KEY
done

echo -e -n "${Green}Please enter your AWS Session Token (optional): \n>> ${Color_Off}"
read SESSION_TOKEN
if [[ "$SESSION_TOKEN" == "" ]]; then
echo -e "${BRed}No AWS Session Token Provided, defaulting to none.${Color_Off}"
fi

aws configure set aws_access_key_id "$ACCESS_KEY"
aws configure set aws_secret_access_key "$SECRET_KEY"
if ! [[ "$SESSION_TOKEN" == "" ]]; then
aws configure set aws_session_token "$SESSION_TOKEN"
fi

default_region="us-west-2"
echo -e -n "${Green}Please enter your default region: (Default '$default_region', press enter) \n>> ${Color_Off}"
Expand All @@ -92,7 +101,7 @@ group_rules="$(aws ec2 authorize-security-group-ingress --group-id "$group_id" -
group_owner_id="$(echo "$group_rules" | jq -r '.SecurityGroupRules[].GroupOwnerId')"
sec_group_id="$(echo "$group_rules" | jq -r '.SecurityGroupRules[].SecurityGroupRuleId')"

data="$(echo "{\"aws_access_key\":\"$ACCESS_KEY\",\"aws_secret_access_key\":\"$SECRET_KEY\",\"group_owner_id\":\"$group_owner_id\",\"security_group_id\":\"$sec_group_id\",\"region\":\"$region\",\"provider\":\"aws\",\"default_size\":\"$size\"}")"
data="$(echo "{\"aws_access_key\":\"$ACCESS_KEY\",\"aws_secret_access_key\":\"$SECRET_KEY\",\"aws_session_token\":\"$SESSION_TOKEN\",\"group_owner_id\":\"$group_owner_id\",\"security_group_id\":\"$sec_group_id\",\"region\":\"$region\",\"provider\":\"aws\",\"default_size\":\"$size\"}")"

echo -e "${BGreen}Profile settings below: ${Color_Off}"
echo $data | jq
Expand Down