Introduction
In this article, I explain the use of the AWS Copilot service.
However, to carry it out, it's necessary to start by analyzing what the AWS Elastic Container Service (ECS) is and how it works, along with its deployment methods.
This is necessary because AWS Copilot performs the implementation and deployment of an application using ECS
💡AWS ECS (Elastic Container Services)
Elastic Container Service ( ECS ) is a scalable container orchestration platform proprietary to AWS.
It is designed to run, stop, and manage containers in a cluster.
Therefore, ECS is AWS's Docker container service that handles the orchestration and provisioning of Docker containers.
This service includes the following concepts:
- ☁️ Task Definition: Describes how to start a Docker container.
- ☁️ Task: This is a running container with the configuration defined in the task definition.
- ☁️ Service: Defines long-running tasks from the same task definition.
- ☁️ Cluster: A logical group of EC2 instances.
- ☁️ Container Instance: This is just an EC2 instance that is part of an ECS cluster and has Docker installed.
⚒️ ECS with EC2 instances
In this model, containers are deployed on EC2 instances (VMs) created for the cluster.
ECS manages them along with the tasks that are part of the task definition
✅ Advantages | ❌ Disadvantages |
---|---|
- Complete control over the type of EC2 instance used is provided. | - When working with EC2, it's necessary for the administrator of this architecture to handle all security updates and scaling of instances. |
- It allows the use of instances that can be optimized depending on what you want to execute. | - The cost is based on the type of EC2 instance running within the cluster and the VPC networks. |
⚒️ ECS with AWS Fargate (Serverless)
In this serverless configuration, the reliance on EC2 instances is eliminated, simplifying the deployment process. Instead, you only need to specify the required CPU and memory combination. AWS Fargate allows for a fully managed and serverless container deployment experience.
✅ Advantages | ❌ Disadvantages |
---|---|
- There are no servers to manage. | - ECS + Fargate supports only one network mode, and this limits control over the network layer. |
- AWS is in charge of the availability and scalability of the containers. | - Cost is based on the CPU and memory you select. The number of CPU cores and GB determines the cost of running the cluster. |
- Fargate Spot is a new capability that can run ECS tasks that are interruption-tolerant at up to a 70% discount compared to the Fargate price. |
💡AWS Copilot
AWS Copilot is a tool used through the AWS command line that simplifies the creation, deployment, monitoring, and operation of containers in ECS using a local development environment
This tool manages the components required for the deployment and operation of an application, such as VPC, load balancers, deployment pipelines, and storage.
Therefore, it's only necessary to provide an application container and minimal configurations, resulting in a faster deployment and focusing on application development.
🔎 Comparison of Task Responsibilities
The services will communicate with each other, so it is necessary to consider the following scenarios:
Activities | Without AWS-copilot | With AWS-copilot |
---|---|---|
Application developmen | 📗 Development team | 📗 Development team |
Container generation | 📗 Development team | 📗 Development team |
Virtual Private Cloud (VPC) Subnets | 📗 Development team | 📙 AWS-Copilot |
Load balancers | 📗Development team | 📙 AWS-Copilot |
Deployment flows (ci/cd) | 📗 Development team | 📙 AWS-Copilot |
Persistent storage of your application | 📗 Development team | 📙 AWS-Copilot |
Synchronize deployment across environments | 📗 Development team | 📙 AWS-Copilot |
🧩 Components
The following table contains the components that are configured when using the AWS Copilot service.
Component | Description |
---|---|
Application | An application is a grouping mechanism for the pieces of your system. |
Enviroment | An environment is a stage in the deployment of an application. |
Service | A service is a single process of long-running code within a container. |
🚀 Deployment with AWS Copilot: A 5-Step Guide
In just 5 steps we can deploy an application using aws-copilot, as shown in the following image.
This allows the development team to only focus on development and not so much on the deployment of the infrastructure.
The first application that is deployed in copilot will make a default configuration and the same will be with a serverless container in fargate.
As seen in the following image, with only 5 steps we can deploy an application.
The steps in the flow are as follows:
- Install AWS Copilot, which will require AWS client credentials.
- Create the Dockerfile for our application.
- Execute
copilot init
in a terminal to initialize. - When running
init
, some questions will appear to answer, such as the application name, service type, service name, and Dockerfile location. - In this final step, a URL will be provided to access the application
🔎 Logs
To obtain the logs of the deployed containers, it is necessary to execute the following command:
\$ copilot svc logs- follow |
---|
📉 Traffic to production
To deploy in production it is necessary to be able to generate different environments, so to generate them it is necessary to execute the following command.
\$ copilot env init |
---|
Subsequently, it is important to be able to modify the manifest file that contains all the application configurations and is located in nombredeaplicacion/manifest.yml
Once the environment configuration is complete, it is necessary to deploy it to production (or another environment, but the following example is in production).
\$ copilot svc deploy ---env production |
---|
🧪Testing
In order to test the deployed application, you can use ApacheBench which allows you to generate traffic to the web application.
For this it is necessary to be able to execute the following command in which you want to generate a number of 5000 transactions to my service with a concurrency of 25 requests at a time.
ab -n 5000 -c 25<http://app12345.us-east-1.elb.amazonaws.com> |
---|
If I do not have the expected response, I can modify my manifest file and horizontally scale the application based on the different environments.
💰 Service Cost
AWS Copilot is distributed by Amazon under an Apache 2.0 license, making it an open-source application.
As an open-source tool, AWS Copilot incurs no additional costs. The pricing is solely determined by the usage of the configured services. This cost-efficient model allows users to leverage the full capabilities of AWS Copilot without incurring any licensing fees.
🎯 Key Takeaways
In conclusion, AWS Copilot stands out for the following features:
AWS Copilot emerges as a robust, open-source AWS tool that streamlines the deployment of production-ready containers in a mere 5 steps, allowing development teams to concentrate on coding rather than grappling with infrastructure intricacies.
Configuration is effortless, demanding only the execution of a few commands and adjustments to the manifest file based on the application's resource requirements.
Addressing horizontal scaling needs is a breeze – a simple modification to the manifest file followed by a deployment is all it takes.
AWS Copilot facilitates the establishment of a CI/CD pipeline for seamless, automatic deployments across various environments.
Effortlessly generate KPIs, set up alarms, and collect metrics with just a few commands through the user-friendly AWS Copilot service.
📚 References
- 📚Title: Presentamos AWS Copilot, Site: Blog de Amazon Web Services (AWS), Author: Nathan Peck,Gabriel Gasca Torres y José Lorenzo Cuéncar, url: <https://aws.amazon.com/es/blogs/aws-spanish/presentamos-aws-copilot/>,
- 📚Title: Introducción a Amazon ECS mediante AWS Copilot, Site: Documentación oficical de AWS, Author: AWS, url: <https://docs.aws.amazon.com/es_es/AmazonECS/latest/userguide/getting-started-aws-copilot-cli.html>
- 📚Title: AWS Copilot*, Site:* AWS*, Author:* AWS, url: <https://aws.amazon.com/es/containers/copilot/>
- 📚Title: Gentle Introduction to How AWS ECS Works with Example Tutorial, Site: Medium*, Author:* Tung Nguyen , Url: <https://medium.com/boltops/gentle-introduction-to-how-aws-ecs-works-with-example-tutorial-cea3d27ce63d>,
Top comments (0)