chore!: default using optional keywork, merge rule map - v5.0.0 refactor #282
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
For now, module have been using a resource statement for each rule type (source_security_group, cidr_blocks, ipv6_cidr_blocks and self).
Using terraform 1.3 optional keywork with default, we should be able to simplify this logic and merge resources in a single map. It should also provide a more clear and concise source code.
Validation are enabled at the variable level to ensure at least one required field is set:
It moves the logic of rule default values from:
to:
It also gives a solution to #281 as prefix_list_ids are now handled at the rule level.
Motivation and Context
Making the module easier to use and less error prone by merging variables that are closely related. It also increase the maintainability as most of the default logic is now handled directly by Terraform.
Breaking Changes
This is breaking the current usage as the rule logic is now handled by a new variable. All the old ones is going to be removed and there is no possibility to handle the changes using
moved
statements.It would require a new major release and Terraform >= 1.3.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectsFor now only the
complete
example have been updated. The terraform apply is running fine in my personnal account.pre-commit run -a
on my pull requestpre-commit is installed and hooks enabled. However the
pre-commit run -a
command hang onterraform validate
. Hooks during commit are clear.