Import IaC into StackGen
StackGen allows you to seamlessly import existing infrastructure into the Topology Canvas, enabling you to visualize and manage your cloud resources. Whether starting from scratch or integrating existing configurations, importing Terraform state (.tfstate
) or JSON files provides a quick and efficient way to work with your infrastructure.
Import IaC
You can import your existing infrastructure in the following ways:
Import Terraform State (.tfstate
)
Use this method to import resources that are already deployed and managed via Terraform.
This option allows you to import Terraform-managed infrastructure into StackGen for visualization and further configuration.
- Navigate to the Topology Canvas.
- Click Import IaC and select Terraform State (
.tfstate
). - Upload your
.tfstate
file. - StackGen will automatically parse the file and render the imported resources in the Topology Canvas.
- Modify and connect the resources as needed.
Import JSON Files
Use this method if you have JSON-based infrastructure definitions from other IaC tools.
This option allows you to import JSON-based infrastructure configurations into StackGen.
- Navigate to the Topology Canvas.
- Click Import IaC and select JSON File.
- Upload your JSON file.
- StackGen will process the file and display the resources within the Topology Canvas.
- You can adjust the configurations and establish dependencies between resources.
Best Practices
- Ensure that the Terraform State (
.tfstate
) or JSON file is correctly structured and contains the relevant resource configurations. - After importing, review resource dependencies and make necessary adjustments before exporting IaC.
- Use the Import Logs feature to check for best practices violations, misconfigurations, or security risks.
By integrating your existing infrastructure into StackGen, you can simplify management, enhance visibility, and enforce governance policies across your cloud resources.
Carve Out appStacks from a TFState Import
After importing a large .tfstate
, you can now split it into multiple smaller appStacks. For example, break down a monolithic state into networking, compute, and storage appStacks, so that different teams can own and manage their parts independently.
-
Selective Imports: choose only the resources you need.
-
Multiple appStacks: create several smaller appStacks from one large
.tfstate
. You can further share your infrastructure across projects. -
Validation Built-In: run
terraform plan
ortofu plan
against the exported appStacks to confirm zero drift.
This helps platform teams enforce compliance and best practices, while enabling developers to quickly discover and reuse approved appStacks.
Once you import a .tfstate
file via Discovery or Create and appStack from Deployment Files, follow these steps:
-
You can select the resources you require from the list of resources and create your appStack.
-
Click Download Iac and Download TFState of Discovery to export your IaC in a Terraform folder.
-
Unzip your
terraform.zip
by running from the downloaded path:unzip iac.zip<your downloaded zip file>
-
Run the following from the
./terraform
folder path:
-
If you want to provision and deploy your IaC using OpenTofu, follow these commands:
tofu init
tofu plan
tofu apply
-
If you want to provision and deploy your IaC using Terraform, follow these commands:
terraform init
terraform plan
terraform apply