fix(project): encode project_ip_access_list ID via EncodeStateID - #122
Closed
nilpntr wants to merge 1 commit into
Closed
fix(project): encode project_ip_access_list ID via EncodeStateID#122nilpntr wants to merge 1 commit into
nilpntr wants to merge 1 commit into
Conversation
mongodbatlas_project_ip_access_list configured GetIDFn to build a plain
"<project_id>-<entry>" terraform ID. terraform-provider-mongodbatlas (v2.x,
plugin-framework) reads this resource with conversion.DecodeStateID and rejects
any ID that doesn't decode to exactly {project_id, entry}, so every observe
failed with:
observe failed: cannot run refresh: refresh failed: error during the reading
operation: the provided resource ID is not correct
Because GetIDFn produces a non-empty ID from parameters, upjet runs the refresh
on the first reconcile and never reaches Create — the entry is never added and
the MR is stuck Synced=False, external-name empty.
Move the external-name handling into config.projectIPAccessListExternalName,
which encodes the ID with the existing encodeAtlasStateID helper (matching the
TF provider's conversion.EncodeStateID over the keys "entry" and
"project_id"). The entry value comes from either cidr_block or ip_address
(mutually exclusive), so the static encodedStateID/encodedStateIDMapped helpers
can't be used directly. The stale GetIDFn override in config/resources/project.go
is removed so the default external-name config applies.
Verified live against a real Atlas project: the IPAccessList reconciles to
Synced=True/Ready=True and the entry appears in the project access list.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Sam Mobach <sam.mobach@rtl.nl>
Collaborator
Collaborator
|
Closing this one as it was included in #128 |
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 of your changes
mongodbatlas_project_ip_access_listconfigured itsGetIDFn(inconfig/resources/project.go) to build a plain"<project_id>-<entry>"terraform ID:But
terraform-provider-mongodbatlas(v2.x, plugin-framework) reads this resource withconversion.DecodeStateIDand rejects any ID that doesn't decode to exactly{project_id, entry}:So every observe fails:
And because
GetIDFnreturns a non-empty ID from parameters, upjet runs the refresh on the first reconcile and never reaches Create — the access-list entry is never added and the MR is stuckSynced=Falsewith an emptycrossplane.io/external-name.This is the same
EncodeStateIDscheme the repo already handles for other Atlas resources viaencodedStateID. This PR:config.projectIPAccessListExternalName(), which builds the ID with the existingencodeAtlasStateIDhelper (keysentry+project_id). Theentryvalue comes from eithercidr_blockorip_address(mutually exclusive), which the staticencodedStateID/encodedStateIDMappedhelpers can't express — hence a small dedicated config rather than a map entry."mongodbatlas_project_ip_access_list"at it inexternalNameConfigs(wasconfig.IdentifierFromProvider).GetIDFnoverride inconfig/resources/project.goso the default external-name config applies (References/LateInitializerkept).cidr_blockandip_address, the two-key round-trip throughDecodeStateID, the error paths, and entry recovery fromexternal-name.I have:
make reviewable testto ensure this PR is ready for review.How has this code been tested
config/external_name_test.go(TestProjectIPAccessListGetIDFn,TestProjectIPAccessListGetIDFn_Errors) — assert the encoded ID decodes back to exactly{project_id, entry}for bothcidr_blockandip_address.v2.12.0): theIPAccessListMR reconciles toSynced=True/Ready=Trueand the entry appears in the project's access list. Before the fix the same MR failed withthe provided resource ID is not correct.