OpenTofu in env zero
env zero provides full support for OpenTofu deployments, allowing you to manage your infrastructure using OpenTofu’s declarative configuration language. OpenTofu is the default Terraform binary in env zero, providing a reliable and open-source alternative to Terraform.Configuration options
OpenTofu version selection
You can specify which version of OpenTofu to use in your template configuration:- Navigate to your template settings
- Open the Advanced settings section
- Select your preferred OpenTofu version from the dropdown

Working directory
Configure the working directory where your OpenTofu configuration files are located:- Root directory: Use the repository root (default)
- Subdirectory: Specify a path relative to the repository root
If your OpenTofu files are in a subdirectory, specify the path in the Working Directory field under Advanced settings.
OpenTofu-specific features
State management
OpenTofu uses the same state management concepts as Terraform:- Local state: Stored temporarily during deployment
- Remote state: Recommended for production environments
- State locking: Prevents concurrent modifications
Variable handling
OpenTofu supports multiple variable input methods:- Environment variables: Set in env zero’s variable management
- Variable files:
.tfvarsfiles in your repository - Command-line variables: Passed via
-varflags - Variable precedence: Command-line > environment > variable files
Provider configuration
Configure OpenTofu providers in your configuration files:main.tf
Deployment workflow
env zero follows OpenTofu’s standard deployment workflow:- Initialize:
tofu init- Download providers and modules - Plan:
tofu plan- Generate execution plan - Apply:
tofu apply- Execute the planned changes - Destroy:
tofu destroy- Remove resources (when needed)
Plan and apply process
The plan step generates a detailed execution plan showing what changes will be made. The apply step uses this plan to make the actual changes to your infrastructure.env zero stores plan files between the plan and apply steps to ensure consistency and allow for review and approval workflows.
Best practices
Remote backend configuration
Configure a remote backend for state management:backend.tf
Module usage
Organize your infrastructure using OpenTofu modules:main.tf
Variable management
Use consistent variable naming and types:variables.tf
Troubleshooting
Common issues
Provider version conflicts- Ensure provider versions are compatible with your OpenTofu version
- Check the OpenTofu provider compatibility matrix
- Use remote backends for production environments
- Enable state locking to prevent concurrent modifications
- Regularly backup your state files
- Check variable precedence order
- Verify environment variables are set correctly in env zero
- Use
tofu consoleto debug variable values
Debugging deployments
Enable detailed logging by setting theTF_LOG environment variable:
TF_LOG=DEBUG- Most verbose loggingTF_LOG=INFO- Standard information levelTF_LOG=WARN- Warning and error messages only
Set the
TF_LOG environment variable in your template’s environment variables section for detailed OpenTofu execution logs.Migration from Terraform
OpenTofu maintains compatibility with Terraform configurations:- Configuration files: No changes required to
.tffiles - State files: Compatible with Terraform state format
- Providers: Use the same provider ecosystem
- Modules: Existing Terraform modules work without modification
Your existing Terraform configurations will work with OpenTofu without any modifications.