Tfvars & Layering

Note: Premium video content requires a subscription.

Terraspace supports looking up tfvar files in conventional locations. This encourages an organized structure.

Tfvars Structure

Tfvar files should be place within the app/stacks/MOD/tfvars folder. Example:

app/stacks/demo
├── main.tf
├── tfvars
│   ├── base.tfvars
│   ├── dev.tfvars
│   └── prod.tfvars
└── variables.tf

You don’t have to specify the -var-file option, the tfvars files are automatically processed and used via layering.

Layering

The the tfvar files are processed and “layered”. Example:

TS_ENV=dev  terraspace up demo -y # merges base and dev
TS_ENV=prod terraspace up demo -y # merges base and prod

Tfvars Layering Docs

Seed Command

The terraspace seed command creates starter tfvars files for you. Examples:

$ terraspace seed network
      create  app/stacks/network/tfvars/dev.tfvars
$ TS_ENV=prod terraspace seed network
      create  app/stacks/network/tfvars/prod.tfvars
$

Tfvars Seed Docs.

More tools: