Given the following Terraform:
terraform {
version = "0.9.8"
backend "consul" {
address = "re.consul.aws-dev.manheim.com:8500"
path = "terraform/jniesen/tf-envs"
}
}
output "env" {
value = "${terraform.env}"
}
After running terraform init && terraform plan && terraform apply
, a statefile is created at terraform/jniesen/tf-envs
which looks like this:
{
"version": 3,
"terraform_version": "0.9.8",
"serial": 1,
"lineage": "c6ca7a3d-95a6-4f6d-90dc-f3cfc7a1c5ce",
"modules": [
{
"path": [
"root"
],
"outputs": {
"env": {
"sensitive": false,
"type": "string",
"value": "nonprod"
}
},
"resources": {},
"depends_on": []
}
]
}
Then add a new environment.
After running terraform env new nonprod && terraform plan && terraform apply
, a statefile is created at terraform/jniesen/tf-envs-env:nonprod
which looks like:
{
"version": 3,
"terraform_version": "0.9.8",
"serial": 1,
"lineage": "c6ca7a3d-95a6-4f6d-90dc-f3cfc7a1c5ce",
"modules": [
{
"path": [
"root"
],
"outputs": {
"env": {
"sensitive": false,
"type": "string",
"value": "nonprod"
}
},
"resources": {},
"depends_on": []
}
]
}
The cool thing to notice is that Terraform appended the -env:nonprod
onto the end of the statefile path.