Skip to content

feat(accesscontextmanager): support in-place updates for IngressPolicy and EgressPolicy#17044

Closed
germancv2 wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
germancv2:fix/ingress-policy-remove-immutable
Closed

feat(accesscontextmanager): support in-place updates for IngressPolicy and EgressPolicy#17044
germancv2 wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
germancv2:fix/ingress-policy-remove-immutable

Conversation

@germancv2
Copy link
Copy Markdown

Description

Remove resource-level immutable: true from ServicePerimeterIngressPolicy and ServicePerimeterEgressPolicy to enable in-place updates via PATCH.

Problem

Both resources are marked immutable: true, which sets ForceNew: true on every field. Any change — even adding a single project to ingress_from.sources.resource — triggers a destroy + create cycle.

This is a non-atomic operation: the old policy is removed first, then the new one is added. During the gap, traffic matching that ingress/egress rule is denied.

Root cause

The Google REST API already supports in-place updates. Both Create and Delete internally use PATCH with updateMask=status.ingressPolicies on the parent perimeter. The same endpoint works for updates — but the Terraform resource never generates an Update function because immutable: true prevents it.

Fix

  • Remove immutable: true at resource level
  • Add update_verb: PATCH and update_url: "{{perimeter}}" → generates resourceXxxUpdate function
  • Mark title as immutable: true at property level (it is an identity field used for matching)
  • Remove the create_before_destroy note (no longer needed — updates are now in-place)

The existing PatchUpdateEncoder in nested_query.go.tmpl handles the update logic:

  1. GET current perimeter state
  2. Find matching policy by identity fields (ingressFrom, ingressTo, title)
  3. Replace the policy in-place in the list
  4. PATCH the perimeter with the updated list

Resources affected

  • google_access_context_manager_service_perimeter_ingress_policy
  • google_access_context_manager_service_perimeter_egress_policy

References

…y and EgressPolicy

Remove resource-level immutable: true from ServicePerimeterIngressPolicy
and ServicePerimeterEgressPolicy. Add update_verb and update_url to enable
the Update function, which uses the same PATCH endpoint already used by
Create and Delete.

The Google REST API supports modifying ingress/egress policies in-place via
PATCH with updateMask=status.ingressPolicies. The previous behavior forced
a destroy+create cycle for any field change, causing a non-atomic gap where
traffic matching the rule was denied.

Changes:
- Remove immutable: true at resource level (both Ingress and Egress)
- Add update_verb: PATCH and update_url: {{perimeter}}
- Mark title property as immutable: true (identity field)
- Remove obsolete create_before_destroy note from descriptions
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Apr 9, 2026
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot requested a review from melinath April 9, 2026 09:57
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@melinath, 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.

@yerbis09
Copy link
Copy Markdown

yerbis09 commented Apr 9, 2026

Closing to reopen from the correct account (CLA author mismatch).

@yerbis09
Copy link
Copy Markdown

yerbis09 commented Apr 9, 2026

Closed CLA confict, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants