-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc_local
executable file
·45 lines (36 loc) · 1.34 KB
/
bashrc_local
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
43
44
45
#!/bin/bash
#
# Install terraform
#
if [ ! -x "$(which terraform 2>/dev/null)" ]; then
export release=AmazonLinux
sudo yum install -q -y yum-utils &>/dev/null
sudo yum-config-manager -q -y --add-repo https://rpm.releases.hashicorp.com/$release/hashicorp.repo &>/dev/null
sudo yum -q -y install terraform &>/dev/null
echo 'plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"' >~/.terraform.rc
fi
if [ ! -x "$(which nano 2>/dev/null)" ]; then
sudo yum install -q -y nano &>/dev/null
fi
if [ ! -x "$(which wscat 2>/dev/null)" ]; then
sudo npm install -g wscat &>/dev/null
fi
#
# Configure shell
#
export AWS_ACCOUNT=$(aws sts get-caller-identity|jq -r .Account)
alias tf="terraform"
alias tfi="terraform init"
function set_region_arg() {
if [ -n "$AWS_REGION" ]; then
export ARG_="-var region=$AWS_REGION"
echo "Deploying to $AWS_REGION"
else
unset ARG_
fi
}
alias tfp="set_region_arg;terraform plan -var account=${AWS_ACCOUNT} $ARG_ -input=false -out tfplan"
alias tfa="terraform apply -auto-approve -input=false tfplan"
alias tfpa="set_region_arg;terraform plan -var account=${AWS_ACCOUNT} $ARG_ -input=false -out tfplan && terraform apply -auto-approve -input=false tfplan"
alias tfd="set_region_arg;terraform destroy -var account=${AWS_ACCOUNT} $ARG_ -auto-approve"
alias gpull='git fetch --all --prune --prune-tags --tags;git pull'