Skip to main content
Warning This document has not been updated for a while now. It may be out of date.
Last updated: 9 Jun 2020

govuk-aws: 17. Terraform Data Structure

Date: 2017-07-14

Status

Accepted

Amends 10. Terraform directory structure

Context

Our various Terraform projects share a significant amount of similar configuration (e.g. remote state buckets, stackname).

Under ADR 10 this is repeated for every project and every stack.

Decision

The data portion of ADR 0010 will now be:

├── data
│   ├── common
│   │   └── <environment>
│   │       ├── common.tfvars
│   │       └── <stackname>.tfvars
│   ├── <project>
│   │   └── <environment>
│   │       ├── common.tfvars
│   │       ├── <stackname>.tfvars
│   │       └── <stackname>_secrets.json

Where:

  • <environment> is the account being deployed to (e.g. 'integration', 'staging')
  • <stackname> is the specific collection of projects (e.g. 'integration-green', 'foo-test')
  • <project> is the project describing the resources to build (e.g. 'puppetmaster', 'frontend')

The tfvar files will be applied in this order:

  • common/<environment>/common.tfvars
  • common/<environment>/<stackname>.tfvars
  • <project>/<environment>/common.tfvars
  • <project>/<environment>/<stackname>.tfvars
  • <project>/<environment>/<stackname>_secrets.tfvars

Consequences

  • Values only need to be defined in one place