cleaning

This is the end, of our elaborate plans

Let stop everything, but in order, or you’ll be good to make a lot of things manually.

1. The echo infrastructure

If you have just played with Terraform states in Consul, don’t forget to enable Consul backend by checking if the “backen.tf” is present in each Terraform project.

[bastion] (ansible_virtualenv) ~/
$ cd ~/ansible_playbooks/echo/terraform/demo/echo/system_socat_green
$ terraform destroy -var-file '../../vars_network.tf' -var-file '../../vars_network_echo.tf' 
$ cd ..

[bastion] (ansible_virtualenv) ~/ansible_playbooks/echo/terraform/demo/echo
$ cd system_haproxy
$ terraform destroy -var-file '../../vars_network.tf' -var-file '../../vars_network_echo.tf' 
$ cd ..

[bastion] (ansible_virtualenv) ~/ansible_playbooks/echo/terraform/demo/echo
$ cd network
$ terraform destroy -var-file '../../vars_network.tf' -var-file '../../vars_network_echo.tf'
$ cd ..

[bastion] (ansible_virtualenv) ~/ansible_playbooks/echo/terraform/demo/echo
$ cd ssl
$ terraform destroy -var-file '../../vars_network.tf' -var-file '../../vars_network_echo.tf'
$ cd ..

2. The infrasecrets infrastructure (without Terraform states in Consul)

Go to the next section if you put Terraform states in Consul.

[bastion] (ansible_virtualenv) ~/
$ cd ~/ansible_playbooks/infrasecrets/terraform/demo/infrasecrets/system
$ terraform destroy -var-file '../../vars_network.tf'
$ cd ../..

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets/terraform/demo
$ cd infrasecrets/network
$ terraform destroy -var-file '../../vars_network.tf' 
$ cd ../..

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets/terraform/demo
$ cd core-network
$ terraform destroy -var-file '../vars_network.tf'
$ cd .. 

3. The infrasecrets infrastructure (with Terraform states in Consul)

Use this secion if you put Terraform states in Consul.


We also HAVE to make sure that each Terraform projects has been initialised and connected to the Consul storage first.
Indeed, Terraform must know that there are previous states in Consul in order to copy them in local.

[bastion] (ansible_virtualenv) ~/
$ cd ~/ansible_playbooks/infrasecrets
$ find . -name "backend.tf.disabled" -exec sh -c 'cp "$1" "${1%.disabled}"' _ {} \;

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets
$ cd terraform/demo/infrasecrets/system
$ terraform init && rm backend.tf && terraform init
$ cd ../.. 

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets/terraform/demo
$ cd infrasecrets/network
$ terraform init && rm backend.tf && terraform init
$ cd ../.. 

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets/terraform/demo
$ cd core-network
$ terraform init && rm backend.tf && terraform init
$ cd ..

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets/terraform/demo
$ cd infrasecrets/system
$ terraform destroy -var-file '../../vars_network.tf'
$ cd ../..

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets/terraform/demo
$ cd infrasecrets/network
$ terraform destroy -var-file '../../vars_network.tf'
$ cd ../.. 

[bastion] (ansible_virtualenv) ~/ansible_playbooks/infrasecrets/terraform/demo
$ cd core-network
$ terraform destroy -var-file '../vars_network.tf'
$ cd .. 

4. The bastion infrastructure

You can now go back to your workstation.

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ cd infrasecrets/terraform/demo/bastion/system
$ terraform destroy -var-file '../../vars_network.tf'
$ cd ..

[workstation] (ansible_virtualenv) ~/demo_big_infra/infrasecrets/terraform/demo/bastion
$ cd network
$ terraform destroy -var-file '../../vars_network.tf'
$ cd ..

5. In the AWS Console

In both regions, delete all AMIs and snapshots:

The AMI panel (EC2): AWS AMIs

The snapshots panel (EC2): AWS snapshots

6. In the Cloudflare Console

Revoke the $5 Load-Balancer subscription:

Cloudflare Load-Balancer

7. No more pages!

I hope you enjoyed this demo and found it useful.

I did not explain or show everything because there are so many things to say (especially on the Ansible parts).

If you have questions , remarks or corrections , send me an email !