The Elastic Container Service (ECS) on AWS is a highly scalable container orchestration service. The service will help you package applications with dependencies for developers and break down a monolithic architecture into microservices, allowing you to completely transform your web application architecture.
ECS helps ease the learning curve that ships with other container orchestration services. By utilizing Amazon ECS, you get a single vendor to manage your cloud services, which allows for vendor accountability, better coordination and integration of services, and streamlined installations and configurations.
As cloud transformations become more common, knowledge of containerization services becomes important for your business and career.
In this article, you’ll learn the primary benefits of using ECS in your environment. You’ll also see some real-world examples of how ECS is being used in businesses to have a significant impact on service delivery. Finally, you’ll get some hands-on experience with Amazon ECS by following the quick start tutorial.
Why Should You Use Amazon ECS?
There are several use cases for which you should consider using ECS. Primarily, ECS is a container orchestration service that eliminates the need for you to install, configure, and manage your own container orchestration infrastructure. It does this by taking advantage of simple API calls and other Amazon AWS services, with deep integration and valuable insights.
At a high level, AWS ECS is a cluster management system that lets you focus on building and scaling your applications instead of operating and managing a dedicated container management infrastructure. Under the hood, it’s basically an EC2 instance with a Docker engine and the ECS agent installed. Although you can primarily manage ECS in the cloud, you can use ECS on-premises as well. For more information on the internals of ECS, be sure to check out the ECS Developer Guide.
Alleviating the Pain Points
So what should this mean for you? Container orchestration helps development teams accomplish much more by alleviating a wide array of pain points. Some other orchestration services may help, but Amazon ECS takes it a step further by giving you the tools to provision, deploy, and monitor containers, coupled with other AWS services for maximum effectiveness.
On top of container orchestration, Amazon ECS empowers teams to grow from a single container to hundreds or even thousands of containers across many EC2 instances without any added complexity. This allows you and your team to focus more on the application building process.
Additional Amazon ECS benefits include:
- Easier maintenance and monitoring with AWS CloudTrail and CloudWatch.
- Integrating Amazon S3 buckets for custom Docker registry.
- Amazon IAM for identity management.
- Service discovery with Route 53.
There are countless other AWS specific features that can’t be integrated with other container orchestration services. That being said, ECS isn’t the only containerization service out there. So how do you know that ECS is in fact the best choice for your environment?
What Separates Amazon ECS From the Pack?
As beneficial as ECS is, it still has competitors in the container orchestration space, even in AWS! The two other container orchestration services are the Elastic Kubernetes Service (EKS for short), and AWS Fargate.
Amazon Elastic Kubernetes Service (EKS) is a way for teams who are deep into Kubernetes to use Amazon’s orchestration tools for Kubernetes. Amazon EKS streamlines Kubernetes on the AWS Cloud, eliminating the need to install and operate your own Kubernetes clusters. ECS and EKS both serve a similar purpose: the orchestration of containers. Since they’re similar in terms of features, why would you choose one over the other, and what makes them different?
The biggest difference is in EKS’ name itself: Kubernetes. Since Kubernetes is an open technology, EKS offers you the flexibility to deploy applications across other platforms. This multi-vendor option prevents you from being tied down to one vendor or provider.
One difference that isn’t as obvious is that EKS doesn’t allow for integration with AWS’s Identity and Access Management (IAM) service. This means that you can’t use AWS’s native access management service for container security and instead will need to use third-party add-ons or native Kubernetes controls.
AWS Fargate is a way to have Amazon automate the creation of ECS Container Instances. Although it’s semantics, there is no difference between Fargate and ECS, since Fargate technically uses ECS for its deployments. The difference comes in that ECS container instances run on EC2, whereas Fargate runs ECS based on the task definitions you configure. Fargate has an additional convenience factor since you no longer need to manage ECS container instances.
Although Fargate is significantly easier to operate than ECS container instances, it has the drawback that you no longer own the cloud infrastructure that it’s running on. In addition, there are some limitations with the integrations between Fargate and other AWS services, such as the Elastic File System, Elastic Block Store, and even some networking.
To recap: ECS allows you to use the Docker containers you already manage on a cloud infrastructure that you control. It allows for the most freedom and autonomy with your integration choices while also providing you the flexibility and reliability of a cloud service.
ECS in Real Life
So who uses ECS and what do they use it for? For that, we can turn to our friends over at GoPro. They use AWS services to help deliver products and experiences with a loosely coupled microservice architecture running on ECS. In fact, they chose ECS specifically for how well it integrated with the Docker service they were already familiar with, and it allowed them to take advantage of other AWS services as well, including IAM and the Simple Queue Service.
More specifically, GoPro didn’t want to use just any container orchestration service. They wanted to use something to keep their developers responsible for the health of the cloud services they were developing. Now, rather than having to keep up with configuration drift across an organization, they are able to manage their ECS instances with an “Infrastructure as Code” mindset, allowing them to focus on code, not maintenance.
Amazon ECS Quick Start Guide
It’s time to quit talking and start doing! Before we begin, be sure you have an AWS environment set up to support a new ECS service. If you’re not sure, check out the Setting Up with Amazon ECS AWS documentation. The documentation will walk you through the basics, such as signing up for AWS, creating an IAM User and Role with the appropriate permissions and policies, and creating a VPC.
For our purposes, we are going to spin up Fargate to manage our ECS instance in this guide. To get started, log into the AWS Management Console, and go to ECS. Once logged in and at the ECS page, you’re ready to go. Start by clicking on the “Get started” button.
The first step is choosing an image for your container. You have a few options here, including NGINX and Apache Tomcat Web Server, or you can also customize your own image. For this example, choose the sample-app image with 512MB of memory and 0.25 vCPU.
The next step is defining a task definition. The task definition comes pre-loaded with the sample-app container definition. Review the default definition settings, and proceed to the next step once done. ECS will create a task execution role if you haven’t assigned or created one yet.
Now that you’ve created a task definition and specified a container definition, configure an ECS service. ECS services launch and maintain copies of the task definition for your cluster.
For this guide, configure an Application Load Balancer, designating port 80 as the listener, as shown below.
In this walkthrough, we’re using AWS Fargate with ECS. In this case, configuring the cluster should be straight forward, as that is the main benefit of using AWS Fargate.
In this step, make sure that the cluster has a unique name.
> If you haven’t designated a specific VPC and Subnet, Amazon ECS will create them for you.
The setup is now complete, and it’s time to fire up the cluster! To do this, select “Review and Launch” and confirm all resources have been configured and created properly. If you have followed the steps of this walkthrough, you should have no problem.
When you click on the “Create” button, you will then be presented with a status page while ECS builds the cluster.
To confirm that the sample application is delivered via the cluster and is properly configured, you can navigate to the load balancer that the tutorial automatically created for you.
To hit the load balancer, find the DNS name at the bottom of the screen, and copy it to your clipboard.
Now navigate to that URL in a browser. The page that appears should display “Your application is now running on a container in Amazon ECS.”
Go Forth, and Containerize!
With that, you now know how to create and launch your first ECS application! Surely by now, you can see how simple it is to deploy containers with Amazon ECS and this quick start guide. And with a little extrapolation, you can imagine how easy it is to deploy a microservices architecture on AWS.
Whether you’ve read this guide to help drive the success of your company or to develop skills you can use in your career, ECS makes it obvious why it has become a premier choice for managing and deploying containers.