In previous article, we package our backend service into a single container. And we learn some basic commands to show container status and the logging, we learn how to setup a simple configuration file to boot the application as well. In this article, we will learn how to coordinate many container deployments using ECS.
First of all, we will create a task definition to serve as a foundation for deploying. Then we will also use Fargate to run containers without having to manage servers.
In ECS page, we choose Task Definitions and then click into the task.
We select the only revision and create new revision.
We click into monolith-service under Container Definitions.
We paste the URI of the monolith container that we just pushed to ECR on image field.
If you forgot the URI, you could find it in ECR=>Repositories.
We click Actions=>Run Task.
We choose Fargate as Launch type. Also, choose Cluster-mysfits-fargate as Cluster. Then choose Mysfits-VPC-xxx as Cluster VPC, Mysfits-PublicOne-xxx as Subnets and finally make sure auto-assign public IP is enable.
Click Run Task.
We can see it shows success message.
Go to cluster and click Cluster-mysifts-fargate. According to AWS, “AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). Fargate makes it easy for you to focus on building your applications. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design.”
Click Tasks tab, we can see tasks are running.
We click the task that the group includes “Family”.
Here we can see the public IP here.
We can curl the host by below command.
Go back to ECS and click logs tab, we are able to see our curl works fine.
After testing, we may stop them now.