Skip to main content
⏳ Estimated read time: 5 min read

IaC in StackGen

The IaC (Infrastructure as Code) section in the StackGen Dashboard provides a read-only view of the generated infrastructure code after configuring resources in the Topology Canvas. This IaC representation includes all necessary dependencies and configurations required to deploy the infrastructure to the selected cloud provider.

You can view the IaC section after configuring resources in the Topology Canvas, which are generated in the form of terraform files.

  • The IaC files cannot be modified directly within the StackGen UI.
  • The generated IaC is structured to include all dependencies and configurations needed for deployment.
  • You can export the IaC to a Git repository or download as .zip for further deployment.

Directory Structure of IaC

StackGen organizes the generated IaC files into a structured directory to ensure modularity and reusability.

There are three main directories in the IaC:

Root Directory

The root directory contains essential metadata and backend configuration files.

File NameDescription
.gitignoreSpecifies files to be ignored when exporting to Git.
.metadataStores metadata related to the generated IaC.
README.mdProvides an overview of the exported IaC.
backend.confDefines backend storage configurations.
backend.tfConfigures remote state management for Terraform.

Terraform Directory (terraform/)

This directory contains the main Terraform configurations for managing cloud resources.

Directory/FileDescription
modules/Stores reusable Terraform modules categorized by resource type.
variables.tfDefines input variables for parameterized deployments.
outputs.tfSpecifies output variables for retrieving resource details post-deployment.
main.tfThe primary Terraform configuration file that integrates various modules.
providers.tfDefines cloud provider settings (AWS, Azure, GCP).
terraform.tfvarsContains predefined values for Terraform variables.

Modules Directory (terraform/modules/)

Modules allow for reusable and modular infrastructure definitions. StackGen automatically organizes modules based on the selected cloud provider.

IaC Management in StackGen

The generated IaC can be managed in the StackGen dashboard directly in the following ways:

View and Manage IaC in the IaC Tab

The IaC tab provides a comprehensive view of your entire Infrastructure as Code (IaC) repository, showing all files and folders related to your infrastructure configuration. The generated IaC can be viewed in the StackGen dashboard directly.

  • The IaC files are auto-generated and cannot be directly modified in the UI.
  • You can review the Terraform configurations to understand the structure before exporting.
note

Additionally, you can reach out to us at support@stackgen.com to enable the following beta features for your teams:

Resolve Policy Violations

If there are compliance issues, policy violations will be displayed in a warning banner. You must resolve violations before exporting the IaC.

Refer to Policy Violations for more detailed information.

Export IaC

You can export your IaC in two ways:

  1. Download IaC (.zip) – Export the Terraform files as a .zip archive.
  2. Push to Git – Directly push the IaC to a connected Git repository.

Deploy to Cloud

Once exported, the IaC can be deployed using the cloud provider's tools:

  • AWS: Terraform CLI or AWS CloudFormation.
  • Azure: Terraform CLI or Azure Resource Manager (ARM) templates.
  • GCP: Terraform CLI or Google Cloud Deployment Manager.
  • Civo: Terraform CLI or Civo Kubernetes Provider.

Next Steps