AWS Copilot is an efficient tool for DevOps engineers, providing a quick way to create a development environment on AWS. It simplifies infrastructure deployment and management with a user-friendly CLI. Ideal for microservices, it reduces costs and saves time, requiring basic knowledge of Docker and Linux.

Step to Build Containerized Application on ECS using AWS Copilot:-

Deployment Architecture Design

What are the Prerequisites to use AWS Copilot?

  • Set up an AWS account.
  • Install the AWS Copilot CLI.
  • Install and configure the AWS CLI.
  • Run aws configure to set up a default profile that the AWS Copilot CLI will use to manage your application and services.
  • Install Docker, Git

Step 1: Launch the Amazon Linux EC2 instance and login using SSH.

Step 2: Install and configure the AWS CLI for AWS Copilot.

Note:

export PATH=/usr/local/bin:$PATH

source ~/.bash_profile

Step 3: Install Docker & Git in Linux Server.

yum install docker git -y

service docker start

chkconfig docker on

Step 4: Install AWS Copilot on Linux Server.

mkdir aws-copilot && cd aws-copilot

sudo curl -Lo /usr/local/bin/copilot https://github.com/aws/copilot-cli/releases/download/v1.28.0/copilot-linux-v1.28.0 \

&& sudo chmod +x /usr/local/bin/copilot \

&& copilot — help

# I am using Amazon linux server so that I need to create a soft link for Copilot binary file to “/usr/bin/copilot” location.

ln -s /usr/local/bin/copilot /usr/bin/copilot

More info: https://aws.amazon.com/getting-started/guides/deploy-webapp-copilot/module-one/

Step 5: Clone the sample web application code

$ git clone https://github.com/aws-samples/aws-copilot-sample-service example

$ cd example

Step 6: Provision Infrastructure with related resources

  • Step 6.1: Check the AWS Copilot Version.
  • # copilot — version
  • Step 6.2: Check commands for AWS Copilot
  • # copilot app
  • Step 6.3: Start copilot interface,
  • # copilot init
  • Select Workload Type: — Load Balanced Web Service (Internet to ECS on Fargate)
  • Step 6.4: Give the Service Name: web-app
  • Step 6.5: Select Docker for Web-app that you have created: > ./SampleApp/Dockerfile

Now the Copilot will now start to create the required infrastructure for your application. During the process, you will see the following output:

  • Step 6.6: Select No for skip the Test Env to Build Prod Env.

For this guide, we will not be deploying a test environment, so enter “N”, and press enter. You will now see the the following output:

  • Step 6.7: Build Prod Env that will run your application.
  • # copilot env init — name prod — profile default — app copilot-guide

Note: may be your application name different as per your Dockerfile. In my case it is “copilot-guide” but may be your case other, please on the below screenshot Step 4.5.

  • Step 6.8: Use default configuration.

This will create the infrastructure in the prod environment, and the output will look something like this:

  • Step 6.9: Deploy the prod environment before deploying the application:
  • # copilot env deploy — name prod
  • Step 6.10: Deploy th application in default env:prod:
  • # copilot deploy

Once copilot init command complete the entire setup, below resources has been created in your was accounts:

  • AWS VPC
  • Subnets
  • Security Group
  • ECS Cluster
  • ECS Service
  • Fargate task
  • Service Discovery
  • ECR Repositories
  • Application Load balancer
  • ACM Certs

Learn More: https://aws.github.io/copilot-cli/

Step 7: Clean Up Resources

  • # copilot app delete

Thanks to read this blog: Please leave your comments of your suggestions and feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *