forked from otakup0pe/awsswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
35 lines (32 loc) · 855 Bytes
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
function awsswitch()
{
local AWS="${1}"
if [ -z "$AWS" ] ; then
echo "invalid aws"
else
if [ "${AWS}" = "none" ] ; then
rm "${HOME}/.awsaccount" &> /dev/null
else
if [ "$AWSSWITCH_CONFIG" != "awscli" ] && ! grep -e "${AWS}" "${HOME}/.aws.yml" &> /dev/null ; then
echo "invalid aws"
else
"${AWSSWITCH_PATH}/awsswitch.sh" use "$1" && eval "$("${AWSSWITCH_PATH}/awsswitch.sh" eval)"
fi
fi
fi
}
function awsregion()
{
local REGION="${1}"
if ! aws ec2 describe-regions | cut -f 3 | grep "$REGION" &> /dev/null ; then
echo "invalid region"
else
AWS_DEFAULT_REGION="$REGION"
export AWS_DEFAULT_REGION
fi
}
function awslist()
{
"${AWSSWITCH_PATH}/awsswitch.sh" list
}