How to get ID from an existing private link

Hi guys

I’m importing an existing private link to an a terraform project and in terraform documentation mention that privatelink id is needed, but I don’t know how to get it.

Terraform:
terraform private link resource

format:

{project_id}-{private_link_id}-{provider_name}-{region}

sample:

$ terraform import mongodbatlas_privatelink_endpoint.test 1112222b3bf99403840e8934-3242342343112-AWS-us-east-1

Do someone knows how to get it from atlas GUI or any other method?

I’ve been tried with some strings but I get this error:

Error: couldn't import peer <bad_pl_id> in project <project_id> with cloud provider name AWS, error: GET Error: couldn't import peer <bad_pl_id> in project <project_id> with cloud provider name <cloud_provider>, error: GET https://cloud.mongodb.com/api/atlas/v1.0/groups/<project_id>/privateEndpoint/<cloud_provider>/endpointService/<bad_pl_id>: 400 (request "PATH_PARAM_PARSE_ERROR") One or more path parameter in the request URI /api/atlas/v1.0/groups/<project_id>/privateEndpoint/<cloud_provider>/endpointService/<bad_pl_id> is malformed.
1 Like

Hello, welcome to MongoDB Community

It is not possible to obtain the ID through the GUI for some resources, only via the API. As far as I remember, this is one of them kkkk.

I needed to import some VPCE’s and Private Links and I needed to get the PL ID from the administration API.

This is the curl

curl --user "{PUBLIC_KEY}:{PRIVATE_KEY}" \
  --digest \
  --header "Accept: application/vnd.atlas.2024-05-30+json" \
  -X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{PROJECT_ID}/privateEndpoint/{PROVIDER_NAME}/endpointService?pretty=true"

PROVIDER_NAME = AWS || GCP || AZURE

https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Private-Endpoint-Services/operation/listPrivateEndpointServices

Hi Sammuel, thanks a lot

What permissions do I need to access this resource?

I’m getting this error, but I have added my IP and it’s actually in an authorized CIDR:

{
  "detail" : "IP address <myip> is not allowed to access this resource.",
  "error" : 403,
  "errorCode" : "IP_ADDRESS_NOT_ON_ACCESS_LIST",
  "parameters" : [ "<myip" ],
  "reason" : "Forbidden"
}%    

Sorry, mentioned in the same link:

“To use this resource, the requesting API Key must have the Project Owner role.”

1 Like

Yes, needs to be a owner

1 Like

Thanks a lot, worked prefectly once I fixed permission

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.