StackGen-HCP Terraform Integration
Overview
StackGen integrates with HashiCorp Cloud Platform (HCP Terraform) to combine StackGen's visual infrastructure design with Terraform’s remote state, policy enforcement, and governance. With this integration, you design infrastructure visually in StackGen, generate production-ready Terraform HCL, and deploy it through HCP Terraform.
StackGen makes it easier to create secure, validated infrastructure blueprints, while HCP Terraform provides remote state management, policy enforcement, and audit trails.
Key Features
The integration combines the simplicity of StackGen with the governance of HCP Terraform. Together, they deliver the following capabilities:
- Visual canvas to design appStacks (infrastructure blueprints),
- Automatic generation of Terraform HCL with HCP backend configuration,
- Built-in security and compliance validation during design,
- Remote state, locking, and run management in HCP Terraform,
- Supports multi-region and multi-environment setups via workspaces.
- Supports import of existing
.tfstatefile and generation of IaC. - Supports adding custom modules through drag and drop.
- Configure best practice policy and scanning through StackGen before deployment. Check out Custom Policies and Compliance documentation to learn more.
Benefits
By using StackGen with HCP Terraform, your platform teams and developers gain several advantages:
- Faster delivery: Skip manual Terraform coding with visual design and auto-generated HCL.
- Governance included: Leverage HCP Terraform for policies, state, locking, and audit logs.
- Security first: Design-time checks reduce misconfigurations before deploy.
- Scale across teams: Use standardized appStacks and workspaces for consistent infra management.
Understanding the Technical Architecture
Loose Coupling for Maximum Flexibility: The integration follows a loosely coupled architecture that preserves flexibility.

Key architectural principles
-
Standard Code Generation: StackGen generates standard Terraform HCL that can be version controlled, modified, and deployed independently.
-
Multi-Environment Support: Different AppStacks can target different HCP Terraform workspaces for environment separation.
-
Regional Deployment: Support for multiple regions through separate workspace configurations.

How It Works
At a high level, the integration follows this flow from design to deployment:
- Design your infrastructure in StackGen with the drag-and-drop canvas.
- Connect the appStack to your HCP Terraform workspace.
- Generate your Terraform HCL with backend configuration.
- Deploy via Terraform CLI, CI/CD, or HCP Terraform runs.
- Manage state, policies, and audit trails in HCP Terraform.

Let's learn how to do use this integration in detail.
Step-by-Step Guide
Prerequisites
Click to view
Before you begin, make sure you have the following in place:
- A StackGen account.
- An HCP Terraform account with at least one organization and workspace configuration.
- Cloud provider credentials (AWS, Azure, or GCP).
- Optional: Terraform CLI or a CI/CD pipeline, if you prefer to run deployments outside the HCP UI.
Set Up Your HCP Terraform Workspace
Click to view
- Log in to your HCP Terraform account.
- Create or select a workspace.
- Configure the following Workspace settings:
- Terraform version
- Execution mode (Remote or Local): We recommend that you use Remote.
- Environment variables or secrets for your cloud provider credentials.
- Ensure you set permissions for your user or service account.
Design Your IaC in StackGen
Click to view
-
Log into your StackGen account.
-
From the StackGen Home page, navigate to appStacks > + New appStack.
-
Create a new appStack from scratch and select your target cloud provider.
-
You can either Add resources (e.g., VPC, subnets, load balancer, database, S3) to the Topology canvas. Or, you import resources from an existing
.tfstatefile.
-
Configure your Resources and resolve any validation warnings.

Connect to HCP Terraform
Click to view
-
From your appStack Topology canvas, click the settings icon ⚙️ to configure your storage backend.
-
Turn on the Enable Storage Backend toggle.
-
From the Select the backend type drop-down, select Cloud (Terraform) as the backend.
-
Enter the following information:
- Hostname (
app.terraform.ioor EU variant) - Organization name
- Project
- Workspace name

- Hostname (
-
Once done, click Save.
Generate and Deploy IaC
Click to view
-
From your appStack Topology canvas, click the Download IaC icon to export your Terraform files.

-
Your backend config will look like the sample config below:
terraform {
cloud {
organization = "your-org"
workspaces {
name = "your-workspace"
}
}
} -
Deploy your infrastructure, using one of the following methods:
-
Local CLI: HCP Terraform runs in CLI push your code directly to your HCP workspace.
Run the following commands via CLI:
terraform initterraform planterraform apply
-
CI/CD pipeline: Commit generated IaC by clicking Push to Git button. Your PR will trigger the Terraform
planActions workflow. Check out how you can Automate Terraform with GitHub Actions.
-
Manage and Evolve
Click to view
With the StackGen - Hasicorp Terraform integration, you can:
-
Monitor runs, logs, and audit trails in HCP Terraform.

-
Update your infrastructure designs in StackGen, regenerate the IaC, and redeploy your infrastructure.
-
Use multiple workspaces for different regions or environments (dev, staging, prod).