-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.sh
35 lines (32 loc) · 805 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
rm "${HOME}/.awsaccount" &> /dev/null
else
if [ "${AWS}" = "none" ] ; then
rm "${HOME}/.awsaccount" &> /dev/null
else
"${AWSSWITCH_PATH}/awsswitch.sh" use "$1" && eval "$("${AWSSWITCH_PATH}/awsswitch.sh" eval)"
fi
fi
}
function awsregion()
{
local REGION="${1}"
if [ -z "$REGION" ] ; then
echo "$AWS_DEFAULT_REGION"
else
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
fi
}
function awslist()
{
"${AWSSWITCH_PATH}/awsswitch.sh" list
}