certificatemanager: support in-place update of self_managed certificate data#1370
Merged
Conversation
…te data (#18257) [upstream:84a818f5947558fea00b84c32102499dd133761e] Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician
merged commit Jul 14, 2026
89a231f
into
terraform-google-modules:master
3 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
google_certificate_manager_certificatecurrently forces recreation whenever a self-managed certificate's data changes, because theself_managedblock and itspem_certificate/pem_private_keyfields (and the deprecatedcertificate_pem/private_key_pemaliases) are markedimmutable.As reported in hashicorp/terraform-provider-google#17312, this makes rotating a self-managed certificate very painful in practice: the certificate is typically in use by a
google_certificate_manager_certificate_map_entryand, transitively, a load balancer, so the delete-then-create cycle fails and the update cannot be applied.The Certificate Manager API already supports updating self-managed certificate data in place via the
certificates.patchmethod withupdateMask=self_managed— this is exactly whatgcloud certificate-manager certificates update --certificate-file --private-key-filedoes.This PR removes
immutablefrom theself_managedblock and its subfields. The resource already declaresupdate_verb: PATCH,update_mask: true, and an asyncupdateaction, so this simply wires the self-managed certificate data into the existing update path.name,location,scope, and themanagedblock remain immutable.A create + update sample step is added (backed by a second, matching cert/key fixture pair) so the generated acceptance test exercises the in-place update and confirms it no longer forces recreation.
I verified locally with
go run . --product certificatemanager --output ... --version gathat the generated resource dropsForceNewonself_managedand that the update function appendsselfManagedtoupdateMaskon change; the generated_generated_test.gonow performs create (cert.pem) → update (cert-updated.pem) with import verification at each step.Fixes hashicorp/terraform-provider-google#17312
Derived from GoogleCloudPlatform/magic-modules#18257