Develop Terraform Locally
How to run Terraform or OpenTofu locally when you need to debug or inspect remote state managed by Bluebricks
Use this guide when you need to run terraform plan or tofu plan locally against infrastructure managed by Bluebricks, for debugging or state inspection.
Before you begin
At least one blueprint is deployed to a Bluebricks environment. If you haven't deployed one yet, follow the Quick Start tutorial
The Bricks CLI is installed and authenticated (
bricks whoamireturns your user)You have access to the git repository containing the Terraform or OpenTofu source code
Step-by-step
Run bricks bp state-config
Replace <ENVIRONMENT_SLUG> with your environment's slug (visible in the Bluebricks app on the environment page):
bricks bp state-config <ENVIRONMENT_SLUG>This generates two files in your current directory:
backend.tf: remote state backend configuration (contains a temporary JWT)bbx-terraform-temp.auto.tfvars: properties from the last successful run (if applicable)
Troubleshooting
Resources keep being recreated: your local environment settings (region, project, or account) likely differ from your Terraform configuration. Make sure local environment variables match. For example, set the AWS region:
export AWS_REGION=eu-north-1Or add explicit provider configuration:
provider "aws" {
region = var.aws_region
}bricks bp state-config fails to create files: the CLI is not authenticated. Run bricks login and try again.
JWT expired during a long session: the token in backend.tf expires after a period. Re-run bricks bp state-config <ENVIRONMENT_SLUG> to generate a fresh token.
Related
Terraform/OpenTofu overview (Docs)
Bricks CLI Overview (Docs)
Last updated

