I have to make connection of aws fargaet container to access documentdb.

0

Hello everyone,

my backend nodejs app in running in fargate container and in logs give me connection error with db. I have documentdb to connect. Additionally, both fargate and documentdb is created in same vpc, also I have connection string in my app.

Enter image description here

like this Enter image description here

this is what in my ecs service task definition section. Enter image description here

Is this error related to connectivity of fargate with documentdb? Enter image description here

1 Answer
0
Accepted Answer

Hello.

It appears that there is a problem communicating from Fargate to Documentdb because a timeout error is being output.
Does DocumentDB's security group allow communication from Fargate?
The default port for DocumentDB is 27017.
I think you can check the security group used by DocumentDB by following the steps in the document below.
https://docs.aws.amazon.com/documentdb/latest/developerguide/db-cluster-view-details.html

profile picture
EXPERT
answered 8 months ago
profile pictureAWS
EXPERT
reviewed 8 months ago
  • For communicating from Fargate to Documentdb I added sg of documentdb in inbound rule of fargate sg like how we do for alb is it correct?

  • Thank you for your reply. You need to set Fargate's security group in the inbound rule of DocumentDB's security group.

  • @Riku_Kobayashi I have added sg of my fargate service in documentdb sg inbound but still getting error.

  • Have you checked the network ACL settings? Also, try launching EC2 in the subnet used by Fargate and see if you can access DocumentDB. If you can access it from the command line from EC2, it may not be a network problem. You may also need to check the code and task definitions you are using.

  • It is able to connect from ec2 via ssh tunneling and what I need to check in code and task definition?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions