AWS Copilot

Cloud Computing

In the following article, I explain what AWS Copilot is, how to use this project, and the ease of implementing it.

Romina Mendez https://r0mymendez.github.io/romymendezblog/
11-14-2023

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:


⚒️ 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.

Image description

The steps in the flow are as follows:

  1. Install AWS Copilot, which will require AWS client credentials.
  2. Create the Dockerfile for our application.
  3. Execute copilot init in a terminal to initialize.
  4. When running init, some questions will appear to answer, such as the application name, service type, service name, and Dockerfile location.
  5. 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:


📚 References

  1. 📚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/>,
  2. 📚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>
  3. 📚Title: AWS Copilot, Site: AWS, Author: AWS, url: <https://aws.amazon.com/es/containers/copilot/>
  4. 📚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>

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Mendez (2023, Nov. 14). Romina Mendez: AWS Copilot. Retrieved from https://r0mymendez.github.io/posts_en/2023-11-18-aws-copilot/

BibTeX citation

@misc{mendez2023aws,
  author = {Mendez, Romina},
  title = {Romina Mendez: AWS Copilot},
  url = {https://r0mymendez.github.io/posts_en/2023-11-18-aws-copilot/},
  year = {2023}
}