-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configs: Simplify required_providers blocks #24763
Conversation
We now permit at most one `required_providers` block per module (except for overrides). This prevents users (and Terraform) from struggling to understand how to merge multiple `required_providers` configurations, with `version` and `source` attributes split across multiple blocks. Because only one `required_providers` block is permitted, there is no need to concatenate version constraints and resolve them. This allows us to simplify the structs used to represent provider requirements, aligning more closely with other structs in this package. This commit also fixes a semantic use-before-initialize bug, where resources defined before a `required_providers` block would be unable to use its source attribute. We achieve this by processing the module's `required_providers` configuration (and overrides) before resources. Overrides for `required_providers` work as before, replacing the entire block per provider.
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @alisdair ! Having those two types, ProviderRequirements and RequiredProviders, drove me a little batty and it's lovely to see a solution using one type in both files & modules.
default: | ||
// should not happen | ||
diags = append(diags, &hcl.Diagnostic{ | ||
Severity: hcl.DiagError, | ||
Summary: "Invalid provider_requirements syntax", | ||
Detail: "provider_requirements entries must be strings or objects.", | ||
Summary: "Invalid required_providers syntax", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 I'm so glad you caught that!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
We now permit at most one
required_providers
block per module (except for overrides). This prevents users (and Terraform) from struggling to understand how to merge multiplerequired_providers
configurations, withversion
andsource
attributes split across multiple blocks.Because only one
required_providers
block is permitted, there is no need to concatenate version constraints and resolve them. This allows us to simplify the structs used to represent provider requirements, aligning more closely with other structs in this package.This commit also fixes a semantic use-before-initialize bug, where resources defined before a
required_providers
block would be unable to use its source attribute. We achieve this by processing the module'srequired_providers
configuration (and overrides) before resources.Overrides for
required_providers
work as before, replacing the entire block per provider.