Deploy NGINX Application on AWS ECS

Search for a command to run...

No comments yet. Be the first to comment.
It’s been a few weeks since the completion of Amazon Web Services (AWS) re:Invent. I wanted to share some thoughts. Unfortunately, Amazon Web Services (AWS) re: Invent 2025 didn’t go as planned. Before the event, I had planned all my sessions, the ke...

The first self-replicating worm that compromised npm packages with cloud token-stealing malware

We all know that since the advent of the COVID-19 pandemic, businesses are embracing cloud computing for its scalability, flexibility, and cost savings. However, these advantages come with a growing attack surface, and cloud security flaws have becom...

Imagine you're in a security assessment with your Compliance Team or an External Assessor, and they point out that your AWS environment CloudWatch Log doesn't have a retention period set. CloudWatch Logs retention is an important part of AWS security...

Another incredible year at AWS re:Inforce, and the 2025 edition in Philadelphia did not disappoint. Over the three days, I gained a deeper understanding of AWS security, reconnected with familiar faces who have become like family, and welcomed new pr...

AWS ECS on Fargate offers a seamless platform for deploying containerized applications with ease and efficiency. In this article, we will guide you through the process of deploying an NGINX application on AWS ECS using Fargate.
AWS ECS (Elastic Container Service) is a highly scalable, high-performance container management service that supports Docker containers and allows you to run applications on a managed cluster of servers. Fargate, on the other hand, is a serverless compute engine for containers that work with ECS, removing the need to manage servers or clusters. Additionally, you can deploy ECS on an EC2 instance, however you would need to manually manage the servers or cluster.
Why are we deploying NGINX? NGINX is a popular open-source web server known for its high performance, stability, and rich feature set. It's often used for load balancing, reverse proxying, and as a web server.
Prerequisites
An AWS account with permission to use ECS
AWS CLI installed
Basic understanding of Docker, NGINX, and AWS AWS ECS

A cluster is a logical grouping of your ECS resources, you would need a cluster to deploy a container. in this post, we will be using the default vpc for the cluster
To create a cluster Through AWS CLI aws ecs create-cluster --cluster-name nginx-application
To Create a cluster via AWS Console
Log in to your AWS Management Console, Navigate to the ECS service, and select “Clusters”. Create a new cluster

A Task Definition in AWS ECS is a blueprint for running containers, specifying details like container images, CPU and memory allocation, environment variables, and networking settings.
To Create a task definition via AWS Console
Go to the Task Definitions page on the ECS console.
Create a new task definition and select “Fargate” as the launch type.
Configure the task with the required settings like task size (CPU and memory).
Add a container definition for your NGINX server. Here, you'll specify the image for NGINX (you can use the official NGINX image from Docker Hub).


A service in AWS ECS creates a task by instantiating a task definition, where a task represents a running container. The service is responsible for managing and maintaining the container's desired state and scalability.
To Create a Service via AWS Console
Return to your ECS cluster and select “Services”.
Create a new service and select the task definition you created.
Configure the service - set the number of desired tasks, and network and security settings.
Launch the service. AWS Fargate will start and manage the containers for you.





Find the public IP of your running task (available in the task details in the ECS console).
Access NGINX by entering the public IP in your web browser. You should see the NGINX welcome page.