Skip to content

Add new compute-network-firewall-policy-with-rules resource #11524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mihhalj
Copy link
Contributor

@mihhalj mihhalj commented Aug 22, 2024

Add a new resource to allow updating all rules in network firewall policy at once.

Fixes
hashicorp/terraform-provider-google#19195

Release Note Template for Downstream PRs (will be copied)

`google_compute_network_firewall_policy_with_rules` (beta)

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 22, 2024
@mihhalj mihhalj force-pushed the network-firewall-policy-rules-resource branch 4 times, most recently from 29fcf77 to 32b6bf7 Compare August 26, 2024 10:44
@mihhalj mihhalj force-pushed the network-firewall-policy-rules-resource branch from 32b6bf7 to 4c29d55 Compare August 26, 2024 12:20
@mihhalj mihhalj marked this pull request as ready for review August 26, 2024 13:12
@github-actions github-actions bot requested a review from NickElliot August 26, 2024 13:12
Copy link

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@NickElliot, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added service/network-security-distributed-firewall and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 26, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 2 files changed, 608 insertions(+))
google-beta provider: Diff ( 6 files changed, 3167 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 541 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_compute_network_firewall_policy_with_rules (3 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_compute_network_firewall_policy_with_rules" "primary" {
  rule {
    rule_name               = # value needed
    security_profile_group  = # value needed
    target_service_accounts = # value needed
    tls_inspect             = # value needed
  }
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 990
Passed tests: 911
Skipped tests: 77
Affected tests: 2

Click here to see the affected service packages
  • compute

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccComputeNetworkFirewallPolicyWithRules_computeNetworkFirewallPolicyWithRulesFullExample
  • TestAccComputeNetworkFirewallPolicyWithRules_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccComputeNetworkFirewallPolicyWithRules_computeNetworkFirewallPolicyWithRulesFullExample[Error message] [Debug log]
TestAccComputeNetworkFirewallPolicyWithRules_update[Error message] [Debug log]

$\textcolor{red}{\textsf{Errors occurred during RECORDING mode. Please fix them to complete your PR.}}$

View the build log or the debug log for each test

@modular-magician modular-magician added awaiting-approval Pull requests that need reviewer's approval to run presubmit tests and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 27, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 2 files changed, 637 insertions(+))
google-beta provider: Diff ( 6 files changed, 3286 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 541 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 991
Passed tests: 910
Skipped tests: 77
Affected tests: 4

Click here to see the affected service packages
  • compute

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccComputeInstanceTemplate_withNamePrefix
  • TestAccComputeNetworkFirewallPolicyWithRules_computeNetworkFirewallPolicyWithRulesFullExample
  • TestAccComputeNetworkFirewallPolicyWithRules_update
  • TestAccComputeTargetHttpsProxy_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Debug log]
TestAccComputeNetworkFirewallPolicyWithRules_computeNetworkFirewallPolicyWithRulesFullExample[Debug log]
TestAccComputeNetworkFirewallPolicyWithRules_update[Debug log]
TestAccComputeTargetHttpsProxy_update[Debug log]
$\textcolor{red}{\textsf{Tests failed when rerunning REPLAYING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Error message] [Debug log]

Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made.

Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer.


$\textcolor{green}{\textsf{All tests passed!}}$

View the build log or the debug log for each test

@mihhalj
Copy link
Contributor Author

mihhalj commented Aug 29, 2024

Could I ask fro review?
I ran my tests locally and they pass - not sure why TestReadPlannedAssetsCoverage* tests and VCR-test are failing.

Copy link

@NickElliot This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link
Contributor

@NickElliot NickElliot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, a couple formatting changes needed

could you link me some of the public documentation on the resource?

Fix formatting

Co-authored-by: Nick Elliot <[email protected]>
@github-actions github-actions bot requested a review from NickElliot August 30, 2024 09:32
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 30, 2024
@mihhalj
Copy link
Contributor Author

mihhalj commented Aug 30, 2024

hi, a couple formatting changes needed

could you link me some of the public documentation on the resource?

Docs:
https://cloud.google.com/firewall/docs/network-firewall-policies
https://cloud.google.com/compute/docs/reference/rest/v1/networkFirewallPolicies

For firewall policy there's a terraform resource (not possible to set rules):
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_network_firewall_policy

And the rules in firewall policy can be configured using:
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_region_network_firewall_policy_rule

The new google_compute_network_firewall_policy_with_rules would allow a user to configure firewall policy with all rules (it was suggested by rileykarson to create a new resource to handle it).

There are similar PRs for regional and org firewall policies:

Copy link

github-actions bot commented Sep 4, 2024

@NickElliot This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 4, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 2 files changed, 637 insertions(+))
google-beta provider: Diff ( 6 files changed, 3286 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 541 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 868
Passed tests: 789
Skipped tests: 77
Affected tests: 2

Click here to see the affected service packages
  • compute

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccComputeInstanceTemplate_withNamePrefix
  • TestAccComputeRegionPerInstanceConfig_removeInstanceOnDestroy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Debug log]
TestAccComputeRegionPerInstanceConfig_removeInstanceOnDestroy[Debug log]
$\textcolor{red}{\textsf{Tests failed when rerunning REPLAYING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Error message] [Debug log]

Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made.

Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer.


$\textcolor{green}{\textsf{All tests passed!}}$

View the build log or the debug log for each test

Copy link
Contributor

@NickElliot NickElliot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NickElliot NickElliot merged commit 2c115a2 into GoogleCloudPlatform:main Sep 5, 2024
12 of 13 checks passed
entertvl pushed a commit to entertvl/magic-modules that referenced this pull request Sep 9, 2024
iyabchen pushed a commit to iyabchen/magic-modules that referenced this pull request Sep 14, 2024
abd-goog pushed a commit to abd-goog/magic-modules that referenced this pull request Sep 23, 2024
niharika-98 pushed a commit to niharika-98/magic-modules that referenced this pull request Oct 7, 2024
@joekohlsdorf
Copy link

joekohlsdorf commented Nov 8, 2024

@mihhalj I have experimented with the new resource a little bit, it isn't great.

Adding a new rule between existing rules yields a plan which recreates all the rules following the new addition. The same happens when deleting a rule when multiple rules exist.
I haven't been able to verify it but when applying this it might even temporarily remove existing firewall while rules are reshuffled causing outages.

@mihhalj
Copy link
Contributor Author

mihhalj commented Nov 15, 2024

@mihhalj I have experimented with the new resource a little bit, it isn't great.

Adding a new rule between existing rules yields a plan which recreates all the rules following the new addition. The same happens when deleting a rule when multiple rules exist. I haven't been able to verify it but when applying this it might even temporarily remove existing firewall while rules are reshuffled causing outages.

joekohlsdorf Thanks for testing and You're right - using this resource when you update/remove/add even only one rule it results in updating all rules - the main goal for this resource is to be able to change many rules at once - it either succeeds and all the rules are updated or it fails and none of the rules are not updated - for example if one of the rule is invalid then the firewall policy won't be updated (there won't be a situation where valid rules are updated and invalid not).

Compare it to the case when you use compute_network_firewall_policy_rule resources for your rules - valid rules will be configured and the invalid not.

@github-actions github-actions bot requested a review from NickElliot November 15, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants