Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I Allow Fargate cluster to access external mongodb database instance

I have built a Fargate cluster which is running my website. The service starts the task for the website properly but stops when it gets to trying to connect to my database instance.

MongoError: failed to connect to server [123.456.789.0:27017] on first connect [MongoError: connection 0 to 123.456.789.0:27017 timed out]

How do I add the Fargate cluster to the security group on my database instance. I don't have a public ip address for the fargate cluster that I can find or a range. I can't find any proper guides on the aws documentation that go over this.

like image 740
chrisaitken Avatar asked Nov 07 '22 12:11

chrisaitken


1 Answers

If mongo is running outside your vpc

  1. If you are running fargate inside private subnet of VPC. The ip address will be NAT ip address found here NAT GATEWAY
  2. If it's running inside public subnet. You can assign public ip address to your fargate task using network interfaces.
like image 85
Somit Srivastava Avatar answered Dec 25 '22 08:12

Somit Srivastava