What is ECS in AWS?
ECS stands for (Elastic Container Service) which is a container management service on AWS that supports Docker containers and allows you to manage your containers on clusters.
What is Fargate?
AWS Fargate is a serverless, pay-as-you-go compute engine that lets you focus on building applications without managing servers.
Steps to deploy your application on ECS:
- Create a task definition and add your image source.
- Create a security group for the cluster
- create a cluster
- create a service
- Visit your website
Let's start our detailed steps journey to deploy our container.
1. Create a task definition and add your image source:
Open your AWS console and search for ECS and click on task definitions then click on create a new task definition
In the configure task definition and containers step give your task a name then add your container name and image URL.
In this example we will use an image on my docker hub from this Link.
Add your container port that you want the application to run on it, I will use port 80 then go to the bottom of the page and click next.
In the configure environment, storage, monitoring, and tags step we will choose AWS Fargate as our app environment to run our application on it.
Operating system will be linux.
CPU will be 0.5 vCPU and Memory will be 1GB.
Click next and review your task details then click create.
2. Create a security group for the cluster
In the search tab, search for EC2 and choose Security Groups from the Network and Security tab and click on create security group.
Give your security group a name and a description, the security group will have two inbound rules:
The first rule will have an all traffic protocol type and will be running on port 80 and the traffic source will Anywhere-ipv4.
The second rule will have an all traffic protocol type and will be running on port 80 and the source will Anywhere-ipv6.
Then click Create security group.
3. create a cluster
Go to clusters from the left side nav and click on create cluster.
Give your cluster a name and choose a VPC, in this example I used the default VPC.
Then click create.
One thing left to finish the mission! 🤗
4. create a service
Go to the cluster that we have created and go to service tab and create a new service.
In the deployment configuration tab specify the application type to be a service, and the task definition choose our task definition that we created in the first step, then type your service name.
In the Networking tab choose a VPC and subnets.
Choose an existing security group and choose our security group the we created the second step.
Then Click create.
Now go to services tab in the cluster your will find the service exists with an active status.
5. Visit your website
Go to tasks tab in the cluster, you will find a new task has been created click on it.
The task will be running and you can access the website via public ip address copy and past it in your browser or click on open address and it will open the website.
Now, welcome on board.
Top comments (3)
Thank you so much that was very helpful
Well done really great detailed info. keep it up
Very informative thanks dude