Push Terraform Code & Branch Strategy
Understand how CloudCanvas generates Terraform, pushes it to your repository, and how main vs feature branches are handled.
ℹ️Prerequisites
Before pushing Terraform code, make sure you have:
- An approved architecture (status
APPROVEDorDEPLOYED) - A connected repository in the Repository tab (GitHub / Azure DevOps / GitLab)
- A backend profile configured in the Backend tab (S3 / Azure Storage / GCS)
- (Optional but recommended) A CI/CD workflow configured in the CI/CD tab
How Terraform Push Works (End-to-End Flow)
- Design & approve your architecture in the Designer and set the status to
APPROVED. - Connect a repository (Repository tab) and configure backend (Backend tab).
- In the CI/CD > Designer sub‑tab, configure workflow steps, backend strategy, and CI provider; then save.
- In the CI/CD > Generate YAML sub‑tab, choose CI provider and generate the pipeline YAML (saved in the workflow config).
- From the Repository tab, click Push Terraform Code; the server generates Terraform + workflow YAML and pushes it into your repo.
Navigate to Architecture Details
From the architectures landing page, click on your architecture to access its details page. For example:/architectures/cmimm8yy1000jumtg506inbij.

Architecture details page with terraform push section
Access Terraform Push
Scroll down on the architecture details page to find the "Push Terraform Code" section and click the button to begin the Terraform deployment process.

Push Terraform Code section with configuration options
đź’ˇ Tip: This process will generate and push all necessary Terraform files for your cloud infrastructure deployment.
Backend & Branch Strategy (main vs feature branches)
In the CI/CD > Designer sub‑tab you will see a Backend Strategy Configuration card. This controls how state is handled for the main branch vs feature branches when you run Terraform from CI/CD.
Main branch (production)
Recommended: Use Remote Backend
- Uses the configured
backend.tf(S3 / Azure Storage / GCS) - Shared remote state for production deployments
- Safe concurrent access with state locking
Feature branches (development)
Default: Use Local State (Recommended)
- Keeps state local to the CI runner for preview / testing
- Does not affect shared production state
- You can opt‑in to
Remote Backendif you really need shared state
How this is used in Terraform push:
The selected strategy is stored in the architecture's cloudConfig.workflow.backendStrategy. When CI/CD pipelines run (for example on GitHub Actions or Azure DevOps), the generated YAML uses this strategy to decide whether to include backend.tf and remote backend blocks for the current branch.
Generate Terraform Code
The system will automatically generate Terraform configuration files based on your architecture design. This process includes:
- Generate main.tf with all resource definitions
- Create variables.tf for configurable parameters
- Generate outputs.tf for resource outputs
- Create provider configurations for your cloud provider
- Set up state management and backend configurations
🚀 Success: All Terraform files are generated based on your architecture design and ready for deployment.
CI/CD integration:
When you later generate CI/CD YAML in the Generate YAML tab, CloudCanvas uses these Terraform files together with your backend strategy to build a branch‑aware pipeline (for example,.github/workflows/<env>-pipeline.yml or azure-pipelines.yml).
View Repository
Click "View Repository" to open the GitHub repository in a new tab and explore the generated Terraform code:
- Navigate to the repository in your browser
- Switch to the branch that contains
cloudcanvas/terraform-in its name - Click on the "Infrastructure" folder to view Terraform files
- Review the generated Terraform configuration files
The Infrastructure folder will contain all the necessary Terraform files for deploying your cloud architecture, including main.tf, variables.tf, outputs.tf, and provider configurations.
Terraform Deployment Features
Infrastructure as Code
Generate complete Terraform configurations for your cloud infrastructure with proper resource definitions and dependencies.
Multi-Cloud Support
Support for AWS, Azure, and GCP with provider-specific configurations and best practices.
State Management
Configured remote state management with your cloud provider for team collaboration and state locking.
CI/CD Integration
Automated Terraform plan and apply workflows integrated with your repository's CI/CD pipeline.
Generated Terraform Files
Core Terraform Files
- • main.tf: Primary resource definitions and configurations
- • variables.tf: Input variables for customization
- • outputs.tf: Output values for resource references
- • providers.tf: Cloud provider configurations
Configuration Files
- • terraform.tfvars: Variable values for your environment
- • backend.tf: Remote state backend configuration
- • versions.tf: Terraform and provider version constraints
- • locals.tf: Local values and computed variables
Deployment Files
- • modules/: Reusable Terraform modules
- • environments/: Environment-specific configurations
- • scripts/: Deployment and validation scripts
- • .github/workflows/: GitHub Actions for Terraform CI/CD
🚀Deployment Process
1. Review Generated Code
Always review the generated Terraform files before deployment to ensure they match your requirements and security standards.
2. Configure Variables
Update terraform.tfvars with your specific values like region, instance sizes, and resource names.
3. Initialize Terraform
Run terraform init to download providers and initialize the working directory.
4. Plan and Apply
Use terraform plan to preview changes and terraform apply to deploy your infrastructure.
đź”§Troubleshooting
Terraform generation fails?
Ensure your architecture design is complete and includes all necessary components. Check that your cloud provider is properly configured.
Repository push fails?
Verify that your GitHub repository exists and that you have the necessary permissions. Check your repository settings and access tokens.
Terraform files incomplete?
Make sure your architecture design includes all necessary components. Some Terraform features require specific architecture elements to be properly configured.
Deployment errors?
Check your cloud provider credentials and permissions. Ensure all required services are enabled in your cloud provider account.
🚀 What's Next?
Your Terraform code is now ready for deployment! You can proceed to deploy your infrastructure or continue with backend initialization.