Skip to content

Cloud Standard

This standard is for management of terraform state files

Purpose

To ensure terraform state files are stored an appropriate location and created for all environments

Requirement

State files should be created, stored and accessed using a backend.tf file, see example below. For AWS accounts they should be stored in the Shareed Services account, which is accessible by your services GitLab runner model. The use of terraform workspaces will automatically create the necessary state files for the different environments/accounts.

terraform {
  backend "s3" {
    bucket         = "nhsbsa-845930604129-replace-terraform" # change word replace with area i.e. citizen
    key            = "${var.service_line[terraform.workspace]}/${var.service_name[terraform.workspace]}/${var.service_name[terraform.workspace]}-infrastructure.tfstate" 
    dynamodb_table = "terraform_state"
    region         = "eu-west-2"
  }
}

Compliance

The CCoE governance function may make spot checks to see if standards are being complied with.