Run Containers in Production Ready Environment using AWS Copilot.

Nipun Parekh
Aug 5 · 5 min read

Why use AWS Copilot?

AWS Copilot is designed for both existing ECS [Elastic Container Service]users, and new ECS users. For those who don’t want to do manual management of lower-level infrastructure, and instead, just start thinking about their application and its lifecycle, it creates application deployment automatically based on production-ready patterns that include best practices designed by ECS engineers and customers over the years.

If you are designing new application architecture, you probably start with a whiteboard or mental diagram and think about how they will talk to each other.

Without Copilot:

You have to create all these things:

VPC subnets, Load Balancers, pipeline, and durable storage.

With Copilot:

You just provide a container and then Copilot handles all the things. So no worries about creating the things :)

Source: link

Before installing Copilot you have got through this prerequisite.

  1. Copilot uses the same credentials as the AWS CLI, If you are using AWS CLI on your system/server you are good to go. If you have not yet installed or configured the AWS CLI first you have to do that.
  2. You have to install Docker also because Copilot used Docker to build and package applications.

Let’s start with AWS Copilot.

First, we will install AWS Copilot:

I am installing this in Linux OS but if you are using another OS then you can follow this Document

curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x copilot && sudo mv copilot /usr/local/bin/copilot && copilot --help

I have already created a Docker image and push that to the docker hub. This is my docker image repository name.

docker pull nipun2020/copilot

Let’s create our Copilot project:

To create a project we have to execute these commands:

copilot init 

Run this command in your application directory, then it asks some questions like what is the name of your project, load balancer, and docker image path in my case it is nipun2020/copilot because I have created docker image and push to docker hub.

This is the list of questions it's going to ask.

  1. Enter your application name. I have entered copilot
1

2. It will ask you workload type. In that, I have selected Load Balanced workload.

2

3. Name your Load balancer, I have given “copilotlb”.

3

4. It will ask you your docker image path/repository name as mentioned I have an application image on the Docker hub, I will enter that docker repository name nipun2020/copilot.

if you have need help you can type “?” [question mark] like this:

4
5

5. It will ask you which port you want to deploy your application to by default it is on port 80 and I have also entered port 80.

6

6. After this all step it will create ECR[Container Repositroy], manifest file and it will ask you would you like to deploy test Environment, I have entered “y” [For yes]

7

7. After all these steps wait for 4–5 mins. Because Copilot is creating our VPC, Loadbalncers and etc. and at last you will get your link from where you will be able to access your application.

Like this:

8

And Boom our Application is running now 🚀.

9

This is running in Test Env. but to run in Production Env. Follow these steps.

  1. Step create new Env. using this command.
copilot env init

Give the Env. name production.

10

2. Change the manifest.YAML file inside your project directory. Do changes according to your requirements.

this is my manifest file inside this directory:

copilotlb/manifest.yml
11 [I have put all things as it is]

3. Now we have to simply execute the last command to deploy our application in production Env.

copilot svc deploy — env production

After waiting for 3–4 mins we will get a new URL from which we can run our application in production Env.

12 [running this application in production Env.]

So we have Run our Container in Production Ready Environment using AWS Copilot⚡🚀✔.

To clean up Env use this command:

copilot app delete — yes
source: link

Thanks for reading. Hope this content will help you.

If you have any query fill free to ask at nipun.p@yudiz.com

Yudiz Solutions

Yudiz refers to the spirit of youth.

Yudiz Solutions

Yudiz refers to the spirit of youth. In coherence with the spirit of innovation and creative spurt that is so natural to youth we at Yudiz believe in thinking beyond the convention to shape multitude of web aspirations.

Nipun Parekh

Written by

DevOps enthusiast.

Yudiz Solutions

Yudiz refers to the spirit of youth. In coherence with the spirit of innovation and creative spurt that is so natural to youth we at Yudiz believe in thinking beyond the convention to shape multitude of web aspirations.