Skip to content

bug: DocDB Replica Set: Db Instances share same port #12289

@vintuwei

Description

@vintuwei

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I am having problems connecting to a document db cluster that is creating on localstack pro. I am using the command below to create the clustered db instances.

I noticed that the db instances created have the same port (in a clustered setup the ports should be different). The cluster is also created with same same port as the instances When i use mongosh command mongosh "mongodb://test:test@localhost:51055/?replicaSet=my-docdb-cluster&ssl=false" to connect to the cluster, i get the error MongoServerSelectionError: Server selection timed out after 2000 ms. How can i resolve this?

awslocal ec2 create-vpc --cidr-block 10.0.0.0/16
awslocal ec2 create-subnet --vpc-id vpc-cf8c1798255a22c34 --cidr-block 10.0.1.0/24
awslocal ec2 create-subnet --vpc-id vpc-cf8c1798255a22c34 --cidr-block 10.0.2.0/24
awslocal docdb create-db-subnet-group --db-subnet-group-name my-subnet-group --db-subnet-group-description "My subnet group" --subnet-ids subnet-9473dfdffa419fb52 subnet-e7cabf8592bbca497
awslocal ec2 create-security-group --group-name my-docdb-sg --description "My DocumentDB Security Group" --vpc-id vpc-cf8c1798255a22c34

awslocal docdb create-db-cluster \
    --db-cluster-identifier my-docdb-cluster \
    --engine docdb \
    --master-username test \
    --master-user-password test \
    --db-subnet-group-name my-subnet-group \
    --vpc-security-group-ids sg-25f8c040a63dd493e
awslocal docdb create-db-instance \
    --db-instance-identifier my-docdb-instance-1 \
    --db-cluster-identifier my-docdb-cluster \
    --db-instance-class db.r5.large \
    --engine docdb
awslocal docdb create-db-instance \
    --db-instance-identifier my-docdb-instance-2 \
    --db-cluster-identifier my-docdb-cluster \
    --db-instance-class db.r5.large \
    --engine docdb`

Expected Behavior

I should be able to connect to the cluster using the cluster host and port

How are you starting LocalStack?

Custom (please describe below)

Steps To Reproduce

I exported my localstack pro license
I then started localstack with the command localstack start -d

Environment

- OS: MacOs
- LocalStack: Locastack Pro
  LocalStack version: Latest
  LocalStack Docker image sha: `sha256:2940c974b75c1d5137b2b110cbbf941c8f6d7ec67512b6ccbef22c21b94975f6`
  LocalStack build date: `2025-02-14`
  LocalStack build git hash: `4abe43294`

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions