-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestroy_v1.sh
executable file
·41 lines (29 loc) · 1.42 KB
/
destroy_v1.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
#######################################################################################
#!/bin/bash
######################################################################################
# Author : DevOps Made Easy
# Email : [email protected]
# Description : Terraform destroy script
# Documentation : https://www.terraform.io/docs/commands/destroy.html
######################################################################################
# Export Path Variable
export PATH=$PATH:/opt
######################################################################################
# If statement to ensure a user has provided a Terraform folder path
if [[ -z "$1" ]]; then
echo ""
echo "You have not provided a Terraform path."
echo "SYNTAX = ./destroy.sh <PATH>"
echo "EXAMPLE = ./destroy.sh terraform/instance"
echo ""
exit
fi
######################################################################################
# The Init command is used to initialize a working directory containing Terraform configuration files.
# This is the first command that should be run after writing a new Terraform configuration
terraform -chdir="$1" init
#The Get command is used to download and update modules mentioned in the root module.
terraform -chdir="$1" get
#The Plan command is used to create an execution plan
terraform -chdir="$1" destroy -auto-approve
######################################################################################