Azure / Azure/Azure-Verified-Modules
[Question/Feedback]: Terraform Variable Validation
- Dominant language
- PowerShell
- Stars
- 580
- Forks
- 161
- Avg merge
- 11h 3m
- Merged PRs (30d)
- 15
Description
### Check for previous/existing GitHub issues
- [X] I have checked for previous/existing GitHub issues
### Description
Wanted to start a discussion around testing in terraform AVM modules. l started investigating the TF testing framework and creating some [unit tests](https://github.com/kevball2/terraform-azurerm-avm-res-resources-resourcegroup/blob/main/tests/unit/unit_tests.tftest.hcl) around variable validation.
Looking at the style guide there is not a lot of defined information yet around what kinds of unit tests we should be looking to create. I started with testing our variable validations to ensure that there was coverage if a validation changed. This lead to the creation of many more tests than I expected. For just the resource group name there were 5 tests to confirm various potential values. All these tests still need to run during the plan phase which would be when the built in TF validation will run.
This brought up several questions:
- Should we be creating custom validations for every variable?
- Does creating custom validation bring value if the built-in provider validation will catch the same errors?
- Should test be created on a case-by-case basis where it helps module consumers to better under the required values without needing to context switch and check documentation.
Hoping for some feedback on what others are doing and any future plans for testing in general.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.