Skip to main content
⏳ Estimated read time: 6 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 projects:

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 the following ways:

  1. Download IaC (.zip): Export the Terraform files as a .zip file.
  2. Download Topology (.json): Download your topology in .json format.
  3. Push to Git: Directly push the IaC to a connected Git repository.

Plan Infrastructure Changes (AWS)

The Plan feature lets you see execution changes before they are applied, so you can review infrastructure changes before deployment. The feature supports the plan operation for AWS. Admins, developers, and DevOps engineers can use it to review infrastructure changes before deployment. Environment settings and the Secret Store are accessible only to DevOps and Admins; these are not accessible to developers. Platform engineers configure project settings. Developers drag and drop resources, configure them, and run Plan to verify that their configuration is correct. Apply and destroy operations will be added in future releases.

You must set up environment configurations before running Plan. To learn more, refer to the Environment Configurations documentation.

Follow these steps to run Plan:

  1. Navigate to your appStack and click the Deploy button.
  2. Click Plan.
  3. Select an environment from the required dropdown. This is a required step for the plan operation.
  4. Click the deployment button (labeled "deployment" on the first run, and "rerun deployment" on consecutive runs).
  5. Upon successful execution, you will see the plan output.

Plan feature - Deploy panel with Plan operation and successful output

On success, a block shows that the plan was successful and details the changes. A log button is available to view logs for init and plan, which show the Terraform or Tofu output. Logs are also viewable in CLI runs, with details of all resources being created or modified.

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