-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws.sh
42 lines (32 loc) · 765 Bytes
/
aws.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
36
37
38
39
40
41
42
function sw-aws-environment() {
if [ ! -z $1 ]; then
echo "Set AWS_PROFILE=$1"
export AWS_PROFILE=$1
return
fi
env=$(cat ~/.aws/config | grep -e '\[.*' | peco | tr -d [ | tr -d ] )
# delete profile prefix if exists
env=$(echo $env | sed -e 's/^profile //')
if [ ! -z $env ]; then
echo "Set AWS_PROFILE=$env"
export AWS_PROFILE=$env
fi
}
function sw-aws-profile() {
sw-aws-environment $@
}
function sw-aws-region() {
read -r -d '' regions <<-'EOF'
us-east-1
ap-northeast-1
EOF
region=$(echo $regions | peco)
if [ ! -z $region ]; then
echo "Set AWS_REGION=$region"
export AWS_REGION=$region
export AWS_DEFAULT_REGION=$region
fi
}
function sso-login-topotal() {
aws sso login --profile topotal-sre
}