feat: Add Conditional Support for policy_variables in Policy Module #8
+54
−0
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.
This PR introduces conditional support for the policy_variables block in the policy module. This allows users to enable or disable the policy_variables block dynamically based on input variables. Additionally, it adds the required variables to both the policy module and the main module to ensure seamless integration.
Changes in
modules/policy
main.tf
Added a
dynamic
block forpolicy_variables
that is created only ifpolicy_variable_enabled
is set totrue
.The block includes:
rule_variables
with a customizable key.An
ip_set
for specifying a list of IP ranges.variables.tf
Added new input variables:
policy_variable_enabled
(boolean) - Toggles the creation of the policy_variables block.rule_variable_key
(string) - Specifies the key for rule_variables (e.g., HOME_NET).rule_variable_definition
(list of strings) - Specifies the IP ranges for the ip_set.Changes in Main Module
main.tf
Passed the
policy_variable_enabled
,policy_rule_variable_key
, andpolicy_rule_variable_definition
variables to the policy module.variables.tf
Added new input variables to match those in the policy module:
Testing
Tested the updated policy module locally.
Confirmed that the
policy_variables
block is created only whenpolicy_variable_enabled
is true.Verified that the input variables are correctly passed from the main module to the policy module.