-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
executable file
·44 lines (34 loc) · 919 Bytes
/
deploy.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
43
44
#!/bin/bash
# Checks the dependencies to run this scripts.
function checkDependencies() {
if [ -z "$TERRAFORM_CMD" ]; then
echo "Terraform is not installed! Please install it first to continue!"
exit 1
fi
}
# Prepares the environment to execute this script.
function prepareToExecute() {
source functions.sh
showBanner
cd iac || exit 1
}
# Deploys the infrastructure based on the IaC files.
function deploy() {
# Initializes Terraform providers and state.
$TERRAFORM_CMD init \
-upgrade \
-migrate-state || exit 1
# Plans/Validates the provisioning.
$TERRAFORM_CMD plan -out /tmp/cicdzerotohero.plan || exit 1
# Applies the provisioning based on the plan.
$TERRAFORM_CMD apply \
-auto-approve \
/tmp/cicdzerotohero.plan
}
# Main function.
function main() {
prepareToExecute
checkDependencies
deploy
}
main