Running Containers on AWS Fargate

Kamlesh Bhatt
4 min readSep 16, 2019

To start with the official statement “AWS Fargate is a compute engine for Amazon ECS and EKS that allows you to run containers without having to manage servers or clusters.”

I have been using Fargate very extensively from the time it was announced and to be honest it’s quite fascinating, i will tell you why in my comparison blog some other time. But for now, let’s focus on how do i use fargate in day to day work.

Running Stateless applications:

Fargate is best when you have a stateless application ( application which don’t store any client data) but can also be used for stateful applications by using s3fuse or simple shell script. But i won’t recommend you doing that for production workloads.

You can refer to my github project for this exercise if you want, we would be using that application as an example.

Firstly, we need to setup our Amazon ECR repo, so that we can build push our docker images to the registry which will be used by our nodejs application later.

Login to your aws account and go to ECS service, click on Repositories and then click on Create repository as shown in below images.

We will be using amazon codebuild and codedeploy to build and deploy the sample application, but anything thing can be used to achieve the same result.

After the build is successful, the image will be pushed to ECR repo that you just created above.

Now, lets create the cluster in which we would run our application. We would be using Fargate, so go to ECS->Clusters->Create Cluster->Network Only. Give your cluster the name you like and click create as shown in below images.

After you have created your cluster, you need to create task definition and service for your application.

Now, let’s create task definition first. As shown in below images.

After you have created the task definition, let’s create service to run our task.

Now, after the service is created, it will automatically run our application, which can be verified by the logs and also to going to the application url/IP provided by aws.

--

--

Kamlesh Bhatt

4x AWS Certified | DevOps Engineer | GCP | Azure | Cloud Platform Engineer | Docker | Kubernetes