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.
You have to create all these things:
VPC subnets, Load Balancers, pipeline, and durable storage.
You just provide a container and then Copilot handles all the things. So no worries about creating the things :)
Before installing Copilot you have got through this prerequisite.
- 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.
- 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:
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.
- Enter your application name. I have entered copilot
2. It will ask you workload type. In that, I have selected Load Balanced workload.
3. Name your Load balancer, I have given “copilotlb”.
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:
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. 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. 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.
And Boom our Application is running now 🚀.
This is running in Test Env. but to run in Production Env. Follow these steps.
- Step create new Env. using this command.
copilot env init
Give the Env. name production.
2. Change the manifest.YAML file inside your project directory. Do changes according to your requirements.
this is my manifest file inside this directory:
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.
So we have Run our Container in Production Ready Environment using AWS Copilot⚡🚀✔.
To clean up Env use this command:
copilot app delete — yes
Thanks for reading. Hope this content will help you.
If you have any query fill free to ask at firstname.lastname@example.org