A demo project for introducting terraform. A short presentation goes with this code base, available here.
This repo currently uses two environments, they are listed in the sub-sections below. The "default" environment is utilized as development because it cannot be removed. You can read more about the "default" environment by clicking here.
Use terraform env select default
to switch to this environment. The
dev.tfvars
should be used with this environment when executing terraform
commands, e.g. terraform plan -var-file=dev.tfvars
. This environment is for
the development team to create a one-for-one likeness with production at a
smaller scale to reduce cost.
Use terraform env select test
to switch to this environment. The
test.tfvars
should be used with this environment when executing terraform
commands, e.g. terraform plan -var-file=test.tfvars
. This environment is to
be used by QA when promoting changes from development prior to going to
production.
For a quick rough script for the demo, please look at demo.md; below are instructions on how to work with this terraform configuration template.
- Switch into the environment you want to create, update, or destroy
infrastructure for, e.g.
terraform env select default
. A list of environments can be made available by typingterraform env list
. Rememberdefault
is the development environment, see the Development ("Default") section for details. - Execute
terraform get
to download any modules that are being used in the configuration. - Execute
terraform plan -out=plan.out -var-file=<env>.tfvars
- be sure to use the right<env>.tfvars
file; see the Environments section for more details. - When you are comfortable with the plan output, you can run
terraform apply plan.out
which will apply the plan from the previous step. The variable file does not need to be supplied again, it is built into the plan output. - To destroy infrastructure simply run
terraform destroy -var-file=dev.tfvars
though there are times where you may want to plan a destroy first. To do so, add the-destroy
flag toterraform plan
and thenapply
the destroy plan.
MIT; see LICENSE for details.