How to identify private endpoint connection strings?

I am using terraform to set up a serverless instance with two private endpoints. I want to then store the private endpoint aware connection strings in a key vault. The issue I am having is that the order of which private endpoint gets created first may not always be the same, and there does not look like there is any way to tell which connection string is for which private endpoint so I can store it accordingly.

For example, if I get the connection strings for my serverless instance it will return something like:
[“mongodb+srv:/”, “mongodb+srv:/”,]

How do I know which is pe-0 and which is pe-1?

Hi @Kate_Lewis - Welcome to the community.

Would you be able to provide the sample .tf files you’re using to create the infrastructure specified in your post? Please redact any credentials and sensitive information before posting here.

Could you also confirm how you’re returning the connection strings in this format? I assume the contents is the value(s) from mongodbatlas_serverless_instance.<resource_name>.connection_strings_private_endpoint_srv but please correct me if I am wrong here.

Lastly, could you help describe the use case / more details on the reason for distinguishing between the two endpoints?

Look forward to hearing from you.