TA-002-P · Question #178
Why is it a good idea to declare the required version of a provider in a Terraform configuration file? 1. terraform 2. { 3. required_providers 4. { 5. aws = "~> 1.0" 6. } 7. }
The correct answer is C. Providers are released on a separate schedule from Terraform itself; therefore a newer. Declaring a required provider version is important because providers are released independently from Terraform itself, and pinning a version ensures your configuration uses the provider release with the exact features and fixes it needs.
Question
Options
- ATo remove older versions of the provider.
- BTo ensure that the provider version matches the version of Terraform you are using.
- CProviders are released on a separate schedule from Terraform itself; therefore a newer
- DTo match the version number of your application being deployed via Terraform.
How the community answered
(29 responses)- A7% (2)
- B3% (1)
- C90% (26)
Why each option
Declaring a required provider version is important because providers are released independently from Terraform itself, and pinning a version ensures your configuration uses the provider release with the exact features and fixes it needs.
Declaring required_providers constrains which version Terraform selects for use; it does not remove or uninstall older versions from the system.
Terraform core and provider versions are managed independently; required_providers version constraints do not enforce matching the Terraform binary version.
Providers have their own release cadence separate from the Terraform CLI; a newer provider version may introduce breaking changes, new resources, or required bug fixes, so declaring a version constraint in required_providers ensures deterministic behavior regardless of which provider version happens to be installed locally.
Provider version constraints relate to the provider's own API compatibility with your configuration and have no connection to the version of the application being deployed.
Concept tested: Terraform provider version constraints and independent release schedules
Source: https://developer.hashicorp.com/terraform/language/providers/requirements
Topics
Community Discussion
No community discussion yet for this question.