apigee: fix permadiff on google_apigee_developer_app.key_expires_in#59
Open
jbbqqf wants to merge 11 commits into
Open
apigee: fix permadiff on google_apigee_developer_app.key_expires_in#59jbbqqf wants to merge 11 commits into
jbbqqf wants to merge 11 commits into
Conversation
…#27071) The Apigee API accepts `keyExpiresIn` as a duration in milliseconds at create time, but the GET payload does not echo it back — instead it returns the absolute expiration timestamp on the credential (`credentials[].expiresAt`). Today the read step flattens this timestamp into the `key_expires_in` state field, so on the next plan the configured duration (e.g. `1807199238981` ms ≈ 21 days) diffs against a millisecond unix timestamp (e.g. `3584153354952`) and forces resource replacement. Marking the field with `ignore_read: true` keeps the user's configured duration in state and stops the spurious replacement. The field remains `immutable` so any genuine config change still triggers a replace as documented. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Stops
google_apigee_developer_appfrom force-replacing on every applywhen
key_expires_inis set. The Apigee API takes a duration on createbut never echoes it back — it returns an absolute expiration timestamp on
the credential. Marking
keyExpiresInwithignore_read: truepreservesthe configured duration in state.
Fixes hashicorp/terraform-provider-google#27071 — see hashicorp/terraform-provider-google#27071
Why
Reproducer (from the issue, confirmed by maintainer @ggtisc):
After
apply, the nextplanshows:That
3584153354952is a unix-millisecond expiration timestamp(
credentials[].expiresAt), not the user's input duration. The providerflattens it into the
key_expires_instate field, which permanentlydiverges from the configured duration. The behavior is determined by the
Apigee API contract — see DeveloperApp / DeveloperAppCredential schemas:
Apigee REST reference.
What changed
mmv1 schema only — adds
ignore_read: trueon thekeyExpiresInfield inmmv1/products/apigee/DeveloperApp.yaml. The field is alreadyimmutable,so a real config change still force-replaces; the only behavior change is
"don't overwrite the user's input with a value the API never returned".
Edge cases tested
-1)# key_expires_in omittedexpiresAt: -1on credential, butdefault_value: "-1"in YAML keeps state stable; with ignore_read no diff is observable on second plankey_expires_in = 1807199238981terraform planshows no diff for as long as the resource existsTest protocol
ignore_read: trueis the standard mmv1 mechanism for "API never echoes this back"; precedent:datafusion/Instance.yaml,storagecontrol/*IntelligenceConfig.yamlGET .../apps/{name}returnscredentials[]withexpiresAt(timestamp), nokeyExpiresInin responseA reviewer with an Apigee org already provisioned can validate by applying
the issue's HCL twice on the BEFORE branch (force-replace observed) and on
this branch (clean second plan).
Resources
ignore_readprecedent:mmv1/products/datafusion/Instance.yaml(PrivateInstance.privateServiceConnectConfig fields)Disclosure
This PR was drafted with assistance from Claude Code as part of a parallel
contribution batch on the magic-modules repository. The schema change was
reviewed manually against the Apigee Discovery doc and against existing
ignore_readusage in the codebase. The author (a human) will review thediff and the modular-magician downstream PRs before requesting maintainer
review. Live BEFORE/AFTER smoke was not run because Apigee organisation
provisioning is too slow for a parallel batch (~30 min per phase); the
maintainer's reproducer in the issue thread already establishes the BEFORE
behavior.