Remote Backend

By default, the generated test harness does not configure a remote backend. You can easily configure the test harness to use a remote backend, though. This can make debugging the test harness easier because:

How To

To configure a remote backend for a test harness create a fixture like so:

app/modules/example/test/spec/fixtures/config/terraform/backend.tf

terraform {
  backend "s3" {
    bucket         = "<%= expansion('terraform-state-:ACCOUNT-:REGION-:ENV') %>"
    key            = "<%= expansion(':PROJECT/:TYPE_DIR/:APP/:ROLE/:MOD_NAME/:ENV/:EXTRA/:REGION/terraform.tfstate') %>"
    region         = "<%= expansion(':REGION') %>"
    encrypt        = true
    dynamodb_table = "terraform_locks"
  }
}

In the build_test_harness method, use it:

terraspace.build_test_harness(
  name: "example-harness",
  modules: {example: mod_path},
  # See: https://terraspace.cloud/docs/testing/test-harness/
  config: "spec/fixtures/config", # <= The fixutre/config containers the terraform/backend.tf
  tfvars: {demo: "spec/fixtures/tfvars/test.tfvars"},
)

More tools: