DEV Community

Romina Mendez
Romina Mendez

Posted on

AWS Copilot

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.

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.

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

  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>,

Top comments (0)