feat(dynamic_backends): Add enable_firewall variable for health check #567
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
This PR adds support for enabling/disabling the creation of firewall rules for health checks, addressing use cases where users manage firewall rules externally (e.g., in shared VPC host projects).
Problem Statement
When using a shared VPC architecture, firewall rules are typically created and managed in the host project rather than the service project. The module currently creates health check firewall rules automatically when
firewall_networksis specified, which can cause conflicts or duplicate rules when users already have dedicated firewall rules for health checks in their host project.Solution
This PR introduces a new variable
enable_firewall(or similar naming) that allows users to opt-in or opt-out of health check firewall rule creation. This provides flexibility for:Changes Made
modules/dynamic_backends/main.tf): Already hadenable_firewallsupport; verified consistencyenable_firewallvariable to root and backend modules with appropriate defaults to maintain backward compatibilityImplementation Details
The firewall rule resource now uses a conditional count:
Backward Compatibility
enable_firewallvariable defaults totrue, ensuring existing configurations continue to work without modificationUsage Example
Disable firewall rule creation (for shared VPC scenarios):
Enable firewall rule creation (default behavior):
Related Issues
Fixes #534
Checklist