Mongo DB archive unable to connect from ec2 with vpc Peering - mongodb

We have configured mongo atlas archiving and trying to connect with aws ec2 with the help of VPC peering. We have already established vpc peering to connect Primary database and it is working fine. But in case of archive db connection we are having connection issue, if we try with ip whitelist then it works fine.
Can any one help us to connect mongo archive db with vpc peering.
Error while connecting with mongo shell
2020-12-12T05:41:15.283+0000 W NETWORK [thread1] Failed to connect to xx.xxx.xx.xx:port after 5000ms milliseconds, giving up.
2020-12-12T05:41:15.283+0000 E QUERY [thread1] Error: couldn't connect to server atlas-online-archive-5da8542bcf09a2545f54fa24-jsraa.a.query.mongodb.net:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:275:13
#(connect):1:6
exception: connect failed

Atlas provides a unified endpoint through which you can query both your live cluster and archived data using the same database and collection name you use in your Atlas cluster. You can't use the unified endpoint over a private connection such as Peering or AWS PrivateLink. You must use a standard internet connection over TLS.
https://docs.atlas.mongodb.com/online-archive/manage-online-archive/#how-service-archives-data
Unfortunately VPC peering is not supported when connecting to the Online Archive

Related

Connecting Tableau to a RDS DB in private tier using web proxy

I have the following architecture in AWS where the RDS DB is publicly unavailable and is inside a private subnet and I am currently connecting to the database through a ec2 jump box located in the public subnet using ssh port forwarding.
To connect to RDS we have two options.
SSH port forwarding setup on EC2
Web Proxy on EC2
I am able to connect using the SSH port forwarding option but I am not able to use Tableau as there is no option in Tableau to connect using .pem file which is required for SSH port connection to go through.
I am trying to see if there is documentation that will explain step by step on the process for setting up web proxy on the EC2 so that I can connect Tableau Desktop with the Database using the Elastic IP of the EC2 instance. Any help appreciated.

mongodb atlas and aws lightsail VPC peering seem to work but node.js server still cannot connect

I am trying to establish VPC peering between my AWS server and MongoDB Atlas. Everything looks good on both AWS VPC dashboard side and MongoDB Atlas/Network Access/Peering.
Also if I run the following code in my AWS lightsail Ubuntu terminal
host cluster0-shard-00-01.a7dlx.mongodb.net, I get the following response: cluster0-shard-00-01.a7dlx.mongodb.net is an alias for ec2-52-201-68-123.compute-1.amazonaws.com. ec2-52-201-68-123.compute-1.amazonaws.com has address 52.201.68.123
So VPC peering seem to work properly. But for some reason I am still getting this connection error in my Node.js application:
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
Could my Mongo URI be the problem? Maybe I need some special URI for VPC?? I tried both urls:
mongodb+srv://admin:<password>#cluster0.123.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
mongodb://admin:<password>#cluster0-shard-00-00.123.mongodb.net:27017,cluster0-shard-00-01.123.mongodb.net:27017,cluster0-shard-00-02.123.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-gz4wg0-shard-0&authSource=admin&retryWrites=true&w=majority

CloudSQL "pg_hba.conf rejects connection for host" pmm-agent

I'm trying to setup a pmm-agent to monitor my db at GCP but I'm getting this error:
pg_hba.conf rejects connection for host
The user is postgres and I can connect trhough psql, but when I'm using it trought a service in machine, this fails. Already check conections for db and network.

Connecting to GCP Cloud SQL using cloud sql proxy

I am following this guide to connect to my GCP Cloud Postgresql - I have a private IP only. When I run
./cloud_sql_proxy -instances=<Instance connection name>=tcp:5432
I get the following (actual references replaced by <Instance connection name>)
2019/04/01 11:46:45 failed to setup file descriptor limits: failed to set rlimit {&{8500 4096}} for max file descriptors: invalid argument
2019/04/01 11:46:45 Listening on 127.0.0.1:5432 for <Instance connection name>
2019/04/01 11:46:45 Ready for new connections
2019/04/01 11:47:28 New connection for <Instance connection name>
2019/04/01 11:49:38 couldn't connect to <Instance connection name>: dial tcp 172.27.160.3:3307: connect: connection timed out
If I run
psql "host=127.0.0.1 sslmode=disable dbname=<db> user=<user> password=<password>"
then I get the following
psql: FATAL: password authentication failed for user "prodigy"
If run the same psql command from a VM instance on the same network as my cloud SQL then connection is just fine.
Your Cloud SQL instance needs to be in the same client's network in order to connect using its private IP.
It will not be possible to connect Cloud SQL (as is) through its private IP outside of the Google Cloud Platform network. In such a case, you could try Cloud Interconnect [2] in order to extend your on-premise network to Google's network so that you can try your connections and see if that works for you.
On the other hand, when using the Cloud SQL Proxy, you need to state being using private IP [3]. If not specified, the proxy will look for the public IP by default.
Let me know how it goes.
[1] https://cloud.google.com/sql/docs/mysql/private-ip
[2] https://cloud.google.com/interconnect/docs/
[3] https://cloud.google.com/sql/docs/postgres/sql-proxy#private-ip
The connection to a Cloud SQL instance using cloud_proxy can happen only if Cloud SQL and cloud_proxy belong the same VPC network [1].
Otherwise cloud_proxy cannot reach Cloud SQL
[1] https://github.com/GoogleCloudPlatform/cloudsql-proxy/issues/164

Linking mongoDB to elasticbeanstalk application

So I have this problem where my node application that is ran by Docker in elasticbeanstalk cant establish a connection with mongoDB instance that is in another elasticbeanstalk environment under the same application(it deployed and ran with Docker aswell).
I have made sure that both of them are in the same VPC and that the mongoDB instance accepts inbound connections from the security group that the node application is under(inbound connections are accepted on port 27017).
Node application uses mongoDBs private IP in the connection string. Should work because they are in the same VPC.
Somehow the node application cant connect to the mongoDB instance and it throws the same error always.
*** DATABASE ERROR: MongoNetworkError: failed to connect to server [private-ip-here:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND private-ip-here private-ip-here:27017] ***
Can anyone give me advice what am I doing wrong ?
Most likely reason would be not configuring mongod.config file in etc directory.
There would be something like :
net:
bindIp: 127.0.0.1
Comment the bindIP or replace it with your server's IP Address.