Publish a Terraform Module
Convert your existing Terraform module into a Bluebricks package in 3 simple steps.
Prerequisites
Bluebricks CLI installed
Authenticated (
bricks login)Existing Terraform module with
.tffiles
Quick Start
You have a Terraform module. Let's publish it.
Step 1: Prepare
Navigate to your Terraform directory and run:
cd /path/to/your-terraform-module
bricks blueprint prepare --source . --iac-type terraformThis creates:
bricks.jsonwith auto-detected variables and outputsOriginal
.tffiles remain in place (no copying by default)
Step 2: Publish
Done. Your module is now available to your organization.
What Just Happened?
Prepare Command
bricks blueprint prepare creates a basic package structure locally:
Creates
bricks.jsonwith minimal metadata:native.type: "terraform"native.path: "." (current directory, no copying)Package name and version
Keeps your
.tffiles in place (no copying by default)
That's it - no API calls, no parsing yet. Just a flat structure.
Publish Command
bricks blueprint publish is where the magic happens:
Creates a zip archive of your package
Resolves external module references (if
--resolve-modulesenabled)Uploads to Bluebricks platform (POST /v1/package)
Bluebricks control plane enriches the metadata:
Parses
variables.tf→ converts topropsinbricks.jsonParses
outputs.tf→ converts tooutsinbricks.jsonDetects provider requirements and dependencies
Validates Terraform syntax
Stores enriched package with full metadata
Makes it available to your organization
The Bluebricks control plane does the heavy lifting - parsing, validation, and enrichment all happen during publish.
Working with Existing Modules
Local Module References
If your Terraform uses local modules:
Bluebricks automatically handles this with --resolve-modules (enabled by default):
What happens:
Finds all modules referenced with
../Copies them to
bricks_modules/directoryUpdates references to point to
./bricks_modules/Includes everything in the published package
Your module becomes self-contained and portable.
Disable Module Resolution
If you don't want to include external modules:
Bluebricks will warn you about external references but won't include them.
Terraform Version
Default version: 1.5.7
Specify a different version in bricks.json:
State Management
Important: No backend.tf Required
Bluebricks automatically manages state using its built-in HTTP backend.
Do not include backend.tf or backend configuration blocks in your Terraform code.
If your Terraform includes backend configuration:
Simply remove the entire backend block. Bluebricks handles state storage, locking, and versioning automatically.
Publishing with Existing State
If you're migrating existing Terraform infrastructure, include your state file:
Requirements:
Place
terraform.tfstatein your Terraform directoryBluebricks packages it with your module
State is stored securely in Bluebricks
State in Bluebricks
When you run a Bluebricks package:
Plan: Bluebricks downloads current state, runs
terraform planApply: Runs
terraform apply, captures new stateStore: Uploads state to Bluebricks (HTTP backend)
Lock: Uses locking to prevent concurrent modifications
State is automatically managed - you don't need to configure remote backends.
Example: Publishing a VPC Module
You have a VPC module:
Publish it:
Use it:
Example: Publishing with Local Modules
Your module references other local modules:
Publish it:
Bluebricks automatically:
Detects
../common/networkingreferenceCopies networking module to
bricks_modules/common/networking/Updates your
main.tfto use./bricks_modules/common/networkingPackages everything together
Your published module is now self-contained.
Example: Migrating Existing Infrastructure
You have live infrastructure managed by Terraform:
Now Bluebricks manages your infrastructure:
State is stored in Bluebricks
Locking prevents conflicts
Full history and audit trail
Team collaboration enabled
Common Options
Prepare Options
--source: Path to Terraform directory--iac-type: Must beterraform--output: Where to create package (default: current directory)--package-name: Custom package name (default: directory name)--refactor: Createbricks.jsonwithout moving files
Publish Options
--src: Package directory (default: current directory)--resolve-modules: Include external modules (default:true)--state: Include terraform.tfstate file
Variables and Outputs Mapping
How Variables Become Props
Your variables.tf:
Becomes props in bricks.json:
Override with properties.json:
How Outputs Become Outs
Your outputs.tf:
Becomes outs in bricks.json:
Generated Package Structure
After prepare:
After publish with --resolve-modules:
Best Practices
Module Design:
Keep modules focused and reusable
Define all variables in
variables.tfDocument all outputs in
outputs.tfUse semantic versioning
Publishing:
Test locally before publishing
Use
--resolve-modulesfor portabilityInclude state for migrations
Version your packages properly
State Management:
Let Bluebricks manage state (don't configure remote backends)
Use
--statewhen migrating existing infrastructureBluebricks handles locking automatically
Variables:
Provide defaults for optional variables
Use clear descriptions
Use proper types (
string,number,bool,list,map)
See also
How to Set Terraform/OpenTofu Version -- pin a specific engine version
How to Work Locally with Remote State -- download state config for local debugging
Creating Blueprints -- compose artifacts into blueprints
Packages overview -- artifact types and packaging concepts
Last updated
Was this helpful?

