aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/deploy.sh
blob: e56088e7c7ec74633e995471b410df0fba6b9530 (plain)
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
46
47
48
49
50
51
52
53
54
# Deploy Script
# Description: Deploy and destroy Terraform
# WARNING: This will most likely destroy any current infrastructure if protections
# are not in place. Be careful!

# Exit if any command has a non-zero status
set -e

echo "WARNING: This script will destroy any infrastructure for testing."
echo "It should not be used once a proper deployment has been setup."
echo "Would you like to continue?"

select yn in "Yes" "No"; do
    case $yn in
    Yes)
        cd ../terraform/
        echo "Would you like to destroy the current infrastructure?"
        select destroy_1 in "Yes" "No"; do
            case $destroy_1 in
            Yes)
                terraform destroy
                break
                ;;
            No)
                echo "Skipping initial destroy..."
                break
                ;;
            esac
        done

        terraform apply

        echo "Would you like to destroy the newly-created infrastructure?"
        select destroy_2 in "Yes" "No"; do
            case $destroy_2 in
            Yes)
                terraform destroy
                break
                ;;
            No)
                echo "Skipping final destroy... Infrastructure will remain."
                break
                ;;
            esac
        done

        break
        ;;
    No)
        echo "Operation cancelled..."
        exit
        ;;
    esac
done
git.ajschof.me — hosted by ajschofield — powered by cgit