Emre Bayram
Emre Bayram

Reputation: 148

AWS ECS Fargate without Load Balancer for internal services

I am trying to load some rest services using cloudformation as ECS Service with Fargate. I don't want a public domain name for these services. I will access them internally from my AWS Lambda functions. I realized AWS Fargate needs load balancing and Load balancer needs certificate and certificates needs a domain name. Probably I am missing something but I tried to load AWS Fargate without a load balancer and I was unable to access it from Lambdas.

The question is; how do I run my services on ECS with Fargate without Load Balancer?

Upvotes: 2

Views: 4870

Answers (1)

jscott
jscott

Reputation: 1051

Use ECS Service Discovery to set up private DNS records that allow your application to discover service endpoints without using a load balancer or having to create public DNS records. Service Discovery works by creating private DNS records in Route 53 that are queryable from within your VPC, so that you can find the IP addresses for all of the tasks running in a service. If you're running multiple tasks you will get multiple A records back, one per task, so you will need to do client-side load balancing by picking a random record in the returned set.

The documentation linked above is a little vague so here are some more specific instructions: When creating your service in the console, in Step 2: Configure Network, check the Enable service discovery integration checkbox. Then specify "create new private namespace" and supply a name for your namespace, such as foo.app. Then select the "Create new discover service" radio button, and specify a name for your service (such as service1). Leave the rest of the settings in the Service discovery (optional) section as default.

Now from within your VPC, you'll be able to look up service1.foo.app and get back A records with the IP addresses of all of the tasks running in the service.

This medium article also has a good summary of how to set up service discovery.

Upvotes: 6

Related Questions