From f370619fbb34ba5f59d4955a24939f15dedc72d0 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 5 Jun 2019 19:48:18 -0300 Subject: Always destroy infrastructure before applying --- TODOs.org | 3 ++- scripts/ci/provision.sh | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TODOs.org b/TODOs.org index 235f6d6..9a6007f 100644 --- a/TODOs.org +++ b/TODOs.org @@ -130,7 +130,8 @@ Also put all of the content of =secrets/*= into vps-state? Maybe rename it to vp Right now, secrets are scattered between the two repositories. By moving I can completely remove =git-crypt= from this repository. ** TODO Run backup on Terraform destroy action instead of manually in =provision.sh= -** TODO Explicitly destroy Droplets before running Terraform apply? +** DONE Explicitly destroy Droplets before running Terraform apply +CLOSED: [2019-06-05 Wed 19:48] ** TODO Store updated =.tfstate= even in case of deployment failure Right now the script fails on Terraform commands before reaching git commands. I should trap the error, store on git and only then fail. ** TODO Fix alias in =bash-profile.sh= diff --git a/scripts/ci/provision.sh b/scripts/ci/provision.sh index 1000a55..b72a0f5 100755 --- a/scripts/ci/provision.sh +++ b/scripts/ci/provision.sh @@ -18,6 +18,10 @@ envsubst < ./scripts/box/run-backup.env.sh | ssh "$TLD" 'cat > /home/vps/run-bac ssh "$TLD" /home/vps/run-backup.sh echo "Done." +echo "Destroying existing infrastructure..." +terraform destroy -input=false -auto-approve +echo "Done." + echo "Running 'terraform plan' and storing the planfile..." terraform --version terraform init -- cgit v1.2.3