Skip to content

Commit

Permalink
Merge pull request #11 from Lugoues/region-support
Browse files Browse the repository at this point in the history
support region in profile or env
  • Loading branch information
dnorth98 authored Oct 21, 2020
2 parents 5c3131c + 7b68f7e commit dafad4c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion aws-connect
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version=1.0.15

# Defaults
action=ssh
aws_region=us-east-1
default_aws_region=us-east-1
aws_profile=''
port=9999
interactive_mode=0
Expand Down Expand Up @@ -161,6 +161,21 @@ if [ -z "${tag_value}" ] && [ -z "${instance_id}" ]; then
exit 1
fi

# If no region parameter passed then try to find one otherwise we default
if [ -z "${aws_region:+x}" ]; then
if [ -n "${aws_profile}" ]; then
aws_region=$(aws --profile "${aws_profile}" configure get region)
fi

if [ -z "${aws_region:+x}" ]; then
aws_region="${AWS_REGION}"
fi

if [ -z "${aws_region:+x}" ]; then
aws_region="${default_aws_region}"
fi
fi

# If instance ID is set via -x, use it
# If both tag and instance ID are set, use instance id
if [ -z "${instance_id}" ]; then
Expand Down

0 comments on commit dafad4c

Please sign in to comment.