Skip to content

Conversation

@benpriestman
Copy link
Contributor

@benpriestman benpriestman commented Oct 24, 2025

When working with this module, I've found it very useful to add tests for different use-cases.
I'd hoped to be able to construct a type for the rule input but I've found this impracticable.
Presumably, this is why the underlying provider hasn't taken this route.
I have added more detail to the input's description.
I've also provided a default value, as the input's description claims its optional.

I tried adding terraform test to the pre-commit hooks.
However, we'd need antonbabenko/pre-commit-terraform#549 to support that with the current config.

Adding a suite of tests, based upon and extending the current examples.
This reduces the risk of unintended breaking changes.
It also makes developing changes eaiser.

Run tests with \`terraform test\`.

Tests are found in the \`tests/\` directory.
They have the same name as the example files for the behaviour they are testing.
In addition, there are WebAcl and WebAclAssociation files that test behaviour not covered in those examples.
Attempted to define a full type for the rule object.
After 800 lines of type definition, it became clear that this would need to become around six times longer to work.
Terraform can't reliably handle `any` types for elements within a list of typed objects.
Adding a pseudo type in the description field instead.
As this variable is marked as optional in its description, also giving it a default value.
@benpriestman benpriestman force-pushed the adding-tests-and-rule-description branch from 7b4d484 to a685177 Compare October 24, 2025 14:05
@benpriestman
Copy link
Contributor Author

Abandoning for now. Might be a useful reference for anyone wanting to do something similar, if - like us - they are wrapping this module in their own one.

@benpriestman benpriestman deleted the adding-tests-and-rule-description branch November 7, 2025 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant