State Management

Download remote Terraform/OpenTofu state configuration to work locally with deployed infrastructure.

Overview

When working with deployments in Bluebricks, state is automatically managed in the cloud. Use bricks bp state-config to retrieve remote state configuration and work with it locally.

Download State Configuration

bricks bp state-config <deployment-slug>

Prerequisites

  • Authenticated with Bluebricks (bricks login)

  • Existing deployment with Terraform/OpenTofu artifacts

  • Local directory with infrastructure code

What This Command Does

The command retrieves the remote state backend configuration and generates two files:

backend.tf - HTTP backend configuration

terraform {
  backend "http" {
    address        = "https://api.bluebricks.co/api/v1/deployments/<uuid>/state"
    lock_address   = "https://api.bluebricks.co/api/v1/deployments/<uuid>/lock"
    unlock_address = "https://api.bluebricks.co/api/v1/deployments/<uuid>/lock"
    username       = "<deployment-uuid>"
    password       = "<jwt-token>"
  }
}

bbx-terraform-temp.auto.tfvars - Deployment variables

Working with Remote State

Initialize Backend

After downloading the configuration, initialize the backend:

View Current State

Run Commands

Once initialized, run standard Terraform/OpenTofu commands:

Example Workflow

Use Cases

Debugging Infrastructure View current state to troubleshoot issues or verify resource configuration.

Local Development Test changes against live state before deploying through Bluebricks.

State Inspection Examine resource attributes and outputs without accessing the cloud console.

Important Notes

  • Read-only recommended: Avoid applying changes directly - use Bluebricks for deployments

  • State locking: Automatic state locking prevents concurrent modifications

  • Credentials: The generated JWT token expires after a period

  • No manual import needed: State is already populated from the deployment

See also

Last updated

Was this helpful?