Troubleshooting Memory Issues with OpenTofu and Terraform
Last updated: July 14, 2025
If you're experiencing high memory usage during Terraform or OpenTofu plan executions, here's how to diagnose and address the issue.
Symptoms
Common signs of memory issues include:
Plan operations taking significantly longer than expected
Memory usage growing continuously during plan execution
Plan operations failing due to out-of-memory conditions
Diagnostic Steps
Enable debug logging by setting the environment variable
TF_LOG=DEBUGin your stack's environment variablesFor more detailed logging (use cautiously as it may contain sensitive information), you can set
TF_LOG=TRACEMonitor memory usage during the run to establish baseline memory requirements
Test the same configuration with different Terraform/OpenTofu versions to isolate version-specific issues
Version Compatibility
If you encounter memory issues, try testing your configuration with different versions of Terraform or OpenTofu. Memory behavior can vary significantly between versions. For example, if Terraform 1.12.1 works well but earlier versions or OpenTofu show memory issues, this may indicate a regression that needs to be reported.
Reporting Issues
If you identify a potential issue in OpenTofu:
Create an issue in the OpenTofu GitHub repository
Include the following information:
Versions tested (both working and problematic versions)
Basic memory usage statistics
Debug logs (ensure to remove any sensitive information)
Infrastructure scale (number of resources, state file size)
When sharing logs publicly, use DEBUG level rather than TRACE to avoid exposing sensitive information. If you need to share more detailed logs, reach out to the maintainers for secure sharing options.