What Is New in Terraform 1.8
This release introduces significant enhancements for testing and managing provider dependencies, alongside a host of other improvements and bug fixes.
| Category | Key Changes |
|---|---|
| New Features | Provider-defined tests, Optional provider attributes, terraform test command
enhancements |
| Enhancements | Improved terraform init output, Config-driven remove, State encryption |
| Bug Fixes | Numerous fixes across core, backends, and the cloud block |
| Deprecations | Deprecated terraform graph command |
How does testing work with providers now?
Terraform 1.8 introduces provider-defined tests, a major shift that allows provider developers to create and ship
custom tests directly within their providers. This means you can run tests for specific cloud resources using
the familiar terraform test command, integrating provider-specific validation logic directly into
your testing workflow.
In practice, this allows for more granular and accurate testing of resources. Instead of just checking if a resource was created, a provider can now test its actual behavior and state in the cloud platform, catching issues that generic Terraform tests might miss.
What's new with provider dependencies?
Optional provider attributes let you mark certain provider dependencies as non-essential. This is useful for modules that can work with multiple providers or when a provider is only needed for specific, advanced features.
You define this in your module's required_providers block by setting optional = true.
This change makes module composition more flexible and prevents errors when an optional provider isn't
configured in the root module.
What improvements were made to the testing command?
The terraform test command now includes a -verbose flag to output more detailed
information during test execution. This is a simple but crucial addition for debugging complex test failures,
giving you better visibility into what each test is actually doing step-by-step.
Additionally, the command now properly handles interrupt signals (Ctrl+C), allowing you to cleanly stop test execution instead of having to wait for the entire test run to complete or force-terminate the process.
Are there any changes to the init process?
Yes, terraform init now provides clearer output when installing providers. The command displays more
informative messages about what it's doing during provider installation, making it easier to understand the
initialization process and troubleshoot when things go wrong.
This might seem minor, but in complex setups with many providers, the improved feedback helps you quickly identify which provider is causing an issue during initialization.
What about state management improvements?
Config-driven remove is now generally available, allowing you to plan and review the destruction of resources
managed by terraform state rm before executing it. This brings the same safety and predictability
to resource removal that you get with terraform apply.
State encryption has also been enhanced with support for AES-GCM and AES-GCM-SIV encryption modes, providing more robust options for securing your state files at rest.
FAQ
Can I use provider-defined tests with any Terraform provider?
No, only providers that have
been updated to implement the new testing functionality will work with provider-defined tests. You'll need to
check with your provider's documentation to see if they support this feature.
What happens if I use a module with optional providers but don't configure them?
Terraform
will simply ignore the optional providers that aren't configured. The module should be designed to handle this
scenario gracefully, either by skipping functionality that requires the missing provider or providing reasonable
defaults.
Is the terraform graph command being removed?
Not immediately. The command has been
deprecated in this release, which means it's still available but will likely be removed in a future version. You
should start exploring alternatives for visualizing your Terraform configurations.
Do I need to change my state encryption configuration?
No, existing encryption configurations
will continue to work. The new AES-GCM and AES-GCM-SIV modes are additional options you can choose to use for
new encryption setups.
How does the verbose flag help with test debugging?
The -verbose flag outputs
detailed information about each test operation as it executes, including which checks are being run and their
results. This makes it much easier to identify exactly where and why a test is failing without having to add
debug statements to your test code.