This demo repo is the source code for my blogpost Terraform all the Things with VSTS.
In order to work with this repo, clone it and then do the following:
- Create the backend storage account.
- Open
state\state.tf
and comment out thebackend
block. - Update the variables in
variables.tf
(or you can override them on the command line). - Run
terraform apply
. This creates a storage account and outputs theaccess_key
. - Uncomment the
backend
block in thestate.tf
file, using values you supplied for theterraform apply
command. - Run
terraform init
, and enteryes
to copy your local state.
- Open
- Add
backend.tfvars
andsecrets.tfvars
to the root folder (these are ignored in the.gitignore
file). Format of these files is listed below. Copy theaccess_key
output from the stateterraform apply
command into thebackend.tfvars
file. - Enter secrets for the database passwords into
secrets.tfvars
. - For each stack (folder):
- Create a workspace (environment).
terraform workspace new dev
to create adev
workspace. If it already exists, then just select it usingterraform workspace select dev
. - Run
terraform init
- this should sync to the backend state. - Run
terraform apply
- Create a workspace (environment).
release.tfvars
is a template file for variables during release. If you add additional variables, remember to add the tokenized values in this file. For more info, see the blog post.
access_key = "long_key_from_azure_storage_acc"
secrets = {
dev = {
sql_admin_password = "ThisIsASuperL0ngP@sswordThatShouldBeSecure1"
}
uat = {
sql_admin_password = "ThisIsASuperL0ngUATP@sswordThatShouldBeSecure1"
}
}