-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Mandatory "features" block is breaking best-practice usage of "terraform validate" #7359
Comments
I want to add a note of appreciation that apart from this, the 1.x -> 2.x upgrade of the AzureRM provider is super painless. I'm really glad about that, good job on the 2.x release line! |
hey @embik Thanks for opening this issue.
Whilst previously Terraform Core would infer a Provider block if one was omitted, where all required fields could be provided via Environment Variables - since the As mentioned in #5866 one option would be to introduce an For context, the AWS Provider (by default) requires a "region" argument is specified on the Provider block - whereas the 1.x versions of the Azure Provider (by default) didn't require anything (since we can run from Azure CLI auth/Env Variables) - as such this issue mostly affects users who are new to Terraform (who are most likely to be affected by this bug). Since It's worth noting that due to the nature of the Azure API's (where these API's are generic, and can have behavioural changes depending on the Subscription/Location being used), unfortunately Terraform's validation functionality can only go so far. When building standalone modules, one option would be to provide end-to-end examples/tests to confirm this provisions infrastructure as you expect it to be used (either with
And the module:
When (in this case running from the root level) -
Ultimately this is a workaround in this instance until the upstream issue on Terraform Core is solved - as you've mentioned that's being tracked in hashicorp/terraform#21408. As such whilst I'd like to thank you for opening this issue I'm going to close this in favour of the upstream issue tracking this bug in Thanks! |
Thank you for the comprehensive answer @tombuildsstuff! I would have preferred to see this change in providers after Terraform upstream fixed this, but I understand your point and hope that the validation part is fixed soon. |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
This is a follow-up issue to #5866 since the discussion there has not seen any follow-up before the bot closed it. I believe the provider behavior violates several best-practices and de-facto behaviors in Terraform providers with the mandatory "features" block.
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.12.26
azurerm-provider: v2.14.0
Affected Resource(s)
azurerm
ProviderTerraform Configuration Files
Any self-contained Terraform module that contains:
But not an explicit
provider
block.Expected Behavior
terraform validate
should validate the syntax and typing of my Terraform module successfully.I expect this to work for several reasons. For one,
terraform validate
explicitly should only validate syntactic validity, see this comment:Using the workaround described in #5866 (comment), I am required to provide specific variable values to variables of my Terraform module when importing it to pass the explicit provider configuration, breaking the intended use of
terraform validate
. It is validating a different kind of thing! Previously, validating a Terraform module using AzureRM was possible, now I need to validate aroot
module that imports another module. That is not the same thing.Moreover, the previously linked issue on hashicorp/terraform mentions adjusting
terraform validate
to ignore provider behavior like this: hashicorp/terraform#21408 (comment)This means that the intended behavior for
terraform validate
in this case would be to work, not fail. The provider is breaking intended behavior of Terraform here in my opinion and it could be easily fixed without changes to core Terraform, at least in the AzureRM case.Last but not least there is no technical reason for requiring this option, since all examples of it are setting it to a default value (empty). The requirement for setting a default value explicitly doesn't make sense and is violating the convention over configuration paradigm, a concept that is frequently applied within Terraform. I understand that this was to make the change from 1.x to 2.x explicit, but 2.x has been out for quite some time now.
Actual Behavior
terraform validate
fails when running on a Terraform module:Steps to Reproduce
terraform validate
on a Terraform moduleImportant Factoids
References
The text was updated successfully, but these errors were encountered: