The purpose of this repo is to show how to use variables of type map and how to dynamically reference them with lookup to build separate Dev and Prod Docker environments using Terraform Workspaces and modules
- Vagrant
- Git
- VirtualBox
git clone https://github.com/achuchulev/tf-maps-lookups.git
cd tf-maps-lookups
vagrant up
Vagrant up will run scripts/provision.sh
that will install:
- Docker
- Terraform
vagrant ssh
sudo su -
cd /vagrant
terraform init
terraform workspace new dev
terraform workspace new prod
terraform workspace select dev
terraform apply
typing dev when asked, to specify which environment you are going to deploy
terraform workspace select prod
terraform apply
typing prod when asked, to specify which environment you are going to deploy
Open the links below in new browser tab to test:
terraform workspace select dev
terraform destroy
typing dev when asked, to specify which environment you are going to destroy
terraform workspace select prod
terraform destroy
typing prod when asked, to specify which environment you are going to destroy
Leave vagrant box ssh, and run
cd tf-maps-lookups
vagrant destroy
confirming yes
once prompted