Skip to content

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

Open
yerbis09 wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
yerbis09:fix/ingress-policy-remove-immutable
Open

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

Conversation

@yerbis09
Copy link
Copy Markdown

@yerbis09 yerbis09 commented Apr 9, 2026

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}}" to generate 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

Fixes hashicorp/terraform-provider-google#26842

References

google_access_context_manager_service_perimeter_ingress_policy: added support for in-place updates, removing the need for destroy+create when modifying ingress policy fields
google_access_context_manager_service_perimeter_egress_policy: added support for in-place updates, removing the need for destroy+create when modifying egress policy fields

…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
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

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

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

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.

google_access_context_manager_service_perimeter_ingress_policy: support in-place updates (remove immutable: true)

2 participants