OpenTofu Workflow
OpenTofu is an open-source infrastructure-as-code (IaC) tool that helps you define and manage cloud infrastructure through code. It offers a transparent, community-driven alternative to Terraform, ensuring open usage without licensing restrictions.
StackGuardianβs integration with OpenTofu simplifies infrastructure workflows, empowering teams to manage infrastructure efficiently and at scale. This integration offers:
- Unrestricted Usage: Built on an Apache 2.0 license, OpenTofu ensures flexibility for all users, including commercial entities.
- Simplified Migration: Existing Terraform workflows can transition to OpenTofu with minimal changes.
- Enhanced Control: Users benefit from custom lifecycle actions, approvals, and workflow automation, tailored to diverse environments.
- Future-Proof Innovation: OpenTofuβs community-driven development ensures compatibility and a user-focused roadmap.
Introductionβ
This guide walks you through creating an OpenTofu workflow on StackGuardian and explores each configuration option in detail.
Source and Parametersβ
OpenTofu workflows on StackGuardian support two source types:
- Git Repository: Fetch configuration code directly from private repositories using version control systems like GitHub or GitLab. Learn more about configuring repositories in Version Control Settings.
- Subscribed Templates: Use pre-built templates from the StackGuardian Library to deploy infrastructure with a no-code approach. These templates simplify deployment and reduce manual configuration efforts.
For more detailed information, refer to the Source and Parameters Guide.
Runtime Environmentβ
Define the deployment and execution environment for your OpenTofu workflow. This includes selecting cloud connectors, specifying variables, and configuring private runners if necessary.
You can reference the StackGuardian Environment Variables for your OpenTofu variables.

OpenTofu Configurationβ
In the OpenTofu Configuration section, you can define runtime behaviors such as state management, lifecycle custom steps, and integrations. This step includes configurations for actions like initializing, planning, applying, or destroying resources.

To learn more about runtime environment settings, see the Runtime Configuration Guide.
Metadata, Review, and Launchβ
After configuring the OpenTofu workflow, click Next to update the workflow metadata (e.g., name, description, and tags). Finally, click Launch to execute the workflow.

Create OpenTofu Workflowβ
Discover additional ways to Create OpenTofu Workflows on StackGuardian.
OpenTofu-Specific Lifecycle Custom Stepsβ
StackGuardian enables users to define custom actions at different stages of the OpenTofu workflow lifecycle. These steps provide fine-grained control over the execution process.
- Pre Init: Execute commands before running
tofu init. This is useful for environment setup and pre-configuration checks. - Pre Plan: Run steps before
tofu planto validate configurations or prepare resources. - Post Plan: Perform actions after the plan is generated, such as analyzing or auditing the plan.
- Pre Apply: Ensure all prerequisites are met before applying changes to infrastructure.
- Post Apply: Execute post-deployment validations or trigger follow-up actions after the apply phase.

For more details, refer to the Lifecycle Custom Steps Guide.
Accessing Workflow Files in StackGuardianβ
StackGuardian provides a clear directory structure for accessing and managing files during workflow execution. For a detailed overview on the key directories, refer to Accessing Workflow Files.
Mounting Custom Binariesβ
StackGuardian supports mounting custom binaries for advanced workflows. This enables users to execute additional logic by integrating custom scripts or binaries directly into the workflow runtime.
Prerequisitesβ
Before configuring custom binaries, ensure that:
- A private runner is used, as custom binaries require controlled environments for security and accessibility.
- The required Terraform/OpenTofu binary is stored on the private runner.