fix: mongodbatlas_privatelink_endpoint creation - #86
Closed
dudu wants to merge 1 commit into
Closed
Conversation
Signed-off-by: Eduardo Nascimento <eduardo.onascimento@stone.com.br>
Collaborator
|
Hi, thanks for raising this issue. |
2 tasks
Contributor
Author
|
@fernandezcuesta created another version on #87 |
Collaborator
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.
Error
mongodbatlas_privatelink_endpoint—groupId is emptyBugReported error
When applying any
privateendpoint.mongodbatlas.crossplane.io/v1alpha1 Resource(directly or via a Composition that embeds one), the resource gets stuck on the
first reconcile with:
The resource never transitions past Observe, so Create is never attempted from
the Crossplane side. Manually issuing the equivalent Atlas REST call
(
POST /api/atlas/v1.0/groups/{groupId}/privateEndpoint/endpointService) withthe same credentials returns 201 Created, confirming the API key,
permissions, project and region are all valid — the failure is entirely
inside the Crossplane provider.
The same symptom applies to
mongodbatlas_privatelink_endpoint_service(KindService).Reproduction
Apply, then inspect the Terraform workspace inside the provider pod
(
/tmp/<resource-uid>/):main.tf.jsonis correct —project_id,provider_name,regionareall populated.
terraform.tfstatecontains:{ "id": "xxx--AWS-US_EAST_1", "project_id": "xxx", "provider_name": "AWS", "region": "US_EAST_1" }idis plaintext and is missingprivate_link_identirely.Root cause
The upstream Terraform provider (
mongodb/mongodbatlasv2.10.0) encodes thestate
idformongodbatlas_privatelink_endpointas abase64-encoded URL query string containing
project_id,private_link_id,provider_name, andregion.Its Read function calls
DecodeStateID(d.Id())on every refresh:This Crossplane provider's resource configurator overrides the upjet defaults
with a plaintext, dash-separated ID format:
mongodbatlas_privatelink_endpointis registered inconfig/external_name.gowithidentifierFromProvider(), which setsconfig.IdentifierFromProvider(DisableNameInitializer: true). On the firstreconcile the
crossplane.io/external-nameannotation is therefore empty, soGetIDFromParamsAndExternalNamebuilds:upjet writes that value into the Terraform state's
idfield before invokingthe upstream provider. On the next refresh the upstream Read function calls
DecodeStateID, which fails because the input isn't valid base64 — thereturned map is empty, every field including
project_idresolves to"",and the SDK call
becomes
Get(ctx, "", "", ""). The Atlas SDK validation fires and returnsgroupId is empty and must be specified.The same mismatch exists for
mongodbatlas_privatelink_endpoint_service(
---separated plaintext on our side, base64 query string upstream).Solution
Drop the custom
GetIDFn/GetExternalNameFnoverrides for both resourcesand rely on
IdentifierFromProviderdefaults(
GetIDFn = ExternalNameAsID,GetExternalNameFn = IDAsExternalName).