Code Generation¶
Audience: Beginners | Status: V1 Core (Terraform — Azure, AWS, GCP) / Experimental (Bicep, Pulumi) | Verified against: v0.43.0
Terraform Starter Export
Terraform starter export is a V1 Core feature — it generates starter code for Azure, AWS, and GCP. Bicep (Azure-only by design) and Pulumi (Azure-only in V1) are available as Experimental features.
Export your visual architecture to Terraform starter code for Azure, AWS, or GCP. Bicep and Pulumi exports are also available (Experimental, Azure only).
How to Generate Code¶
From the Inspector Panel¶
- Select any block on the canvas.
- Click the Code tab in the Inspector Panel (right side).
- The tab shows the generated code for the selected block.
From the Build Menu¶
- Go to Build → Generate Code in the menu bar.
- This generates code for the entire architecture.
Supported Formats¶
| Format | Providers | Output | Status |
|---|---|---|---|
| Terraform | Azure, AWS, GCP | HCL configuration (default) | V1 Core |
| Bicep | Azure only (by design) | Azure Bicep templates | Experimental |
| Pulumi | Azure only (multi-cloud in V2) | Pulumi TypeScript configuration | Experimental |
Terraform is selected by default. To access Bicep or Pulumi, enable the Advanced toggle in the code preview panel — this reveals the format selector. Click Copy to copy the generated code to your clipboard.
Multi-Cloud Output¶
CloudBlocks generates Terraform starter code for the active workspace provider (Azure, AWS, or GCP). Switching the provider tab creates a new workspace for that provider after confirmation; any previously generated output is cleared and the generator resets to Terraform when the current selection is incompatible.
Provider Coverage
Provider coverage varies by template, resource, and export path. Terraform starter export supports all three providers. Bicep is Azure-only. Pulumi is Azure-only.
Provider-Specific Output¶
Each provider generates idiomatic Terraform using its native resource types:
| Provider | Provider block | Example resources | Default region |
|---|---|---|---|
| Azure | azurerm |
azurerm_resource_group, azurerm_linux_web_app |
eastus |
| AWS | aws |
aws_instance, aws_db_instance |
us-east-1 |
| GCP | google |
google_cloud_run_v2_service, google_sql_database_instance |
us-central1 |
AWS and GCP output includes # TODO comments for resource configurations that the visual model does not capture (e.g., ECS task definitions and ALB listener wiring for AWS, Cloud Functions source config and firewall rules for GCP). These are marked for you to fill in before applying.
Each provider remembers your last entered region when you switch between providers during a session.
Region Validation¶
Each provider validates the region input against a curated allowlist of commonly used regions. If you enter an unsupported region, the generator returns an error in this format:
Regions (not availability zones) are validated — for example, us-east-1 is valid for AWS, but us-east-1a is not.
What the Starter Code Teaches You¶
The Terraform starter code shows you:
- How your visual architecture translates to infrastructure-as-code
- Which Terraform resources correspond to each block on your canvas
- How connections between blocks map to resource references in code
- Basic Terraform structure: providers, resources, variables, and outputs
This is designed for learning — review the code to deepen your understanding of cloud infrastructure.
Limitations¶
- Terraform starter code is designed for learning and prototyping — review and adapt it before using in production.
- AWS and GCP output uses
# TODOcomments for fields the visual model does not capture — fill these in before applying. - Not all resource properties are captured in the generated output.
- Complex networking configurations may need additional manual setup.
- The generator does not handle state management or deployment orchestration.
- Bicep is Azure-only by design (Bicep is an Azure-native language). Pulumi multi-cloud support is planned for V2.
What's Next?¶
| Goal | Guide |
|---|---|
| Browse architecture patterns | Templates |
| Build from a blank canvas | Blank Canvas Mode |
| Understand connection semantics | Core Concepts |
| Try guided learning scenarios | Click the Learn button in the menu bar |