AWS Copilot - launch and manage containerized applications quickly 🐳

mubbashir10

Mubbashir Mustafa

Posted on January 31, 2022

AWS Copilot - launch and manage containerized applications quickly 🐳

AWS Copilot is an open-source CLI-based tool by the AWS team which lets you deploy containerized services easily by running a few simple commands. Behind the scenes, AWS takes care of all the infrastructure provisioning and configuration.

Before we begin, it's assumed that you have already containerized your application and it's ready to be deployed. If not, you can clone this sample repo and follow along.

Step 1

Currently, AWS Copilot doesn't work with root users and you need to create an IAM user with programmatic access. Go to IAM and create a new IAM account with programmatic access

Note: ℹ️ It's not mentioned in the documentation which policies are needed for AWS Copilot to work, see this github issue. For the sake of this tutorial you can give Administrator Access to your role.

Step 2

Install the AWS Copilot, if you are on a mac and use homebrew, you can simply run

brew install aws/tap/copilot-cli
Enter fullscreen mode Exit fullscreen mode

For other OS, grab the relevant binary and install that

Verify the installation by running copilot -v

AWS Copilot Version

Step 3

Inside your app folder, run

copilot init
Enter fullscreen mode Exit fullscreen mode

It will ask you to name your application, provide any name

AWS Copilot Init

Next, select the application type (for this tutorial I am selecting Load Balanced Web Service

AWS Copilot service type selection

Next, it will ask for the name of the service, provide any suitable name

AWS Copilot service name selection

If there are multiple Dockerfiles present, it will ask you to pick the desired one

AWS Copilot Dockerfile suggestion

It will begin the build process now

AWS Copilot Init Completed

Once the build is ready, it will ask you if you would like to deploy your service to a test environment, select Yes

AWS Copilot Service deploy option

Wait for it to finish the process, once finished it will give you a URL to the service

AWS Copilot Service Deployment

Grab the URL and test it in a browser
AWS Copilot live service

Step 4

Now set up a pipeline for automated workflows (CI/CD)

Inside your app run

copilot pipeline init
Enter fullscreen mode Exit fullscreen mode

AWS Copilot pipeline

git add copilot/pipeline.yml copilot/buildspec.yml copilot/.workspace && git commit -m "Adding pipeline artifacts" && git push
Enter fullscreen mode Exit fullscreen mode

AWS Copilot CI/CD

copilot pipeline update
Enter fullscreen mode Exit fullscreen mode

AWS Copilot

Once the pipeline finishes, you can verify the changes by visiting the same URL again
AWS Copilot CI/CD Changes Demo

Cleanup

To delete the app just run copilot app delete
Delete AWS Copilot App


AWS Copilot takes the hassle of provisioning and managing infrastructure and lets you deploy your containerized applications quickly. Behind the scenes, it creates everything for you (Cloud formation template, AWS ECR repo, AWS Code Pipeline, AWS Code build project, AWS ECS task definition, AWS ECS Cluster, AWS ECS Service, AWS Load balancer, Security groups, etc.
If you need more granular control and are interested in deploying your dockerized application on AWS ECS manually, you can follow the step-by-step tutorial here.


Let's connect:

Linkedin: https://www.linkedin.com/in/mubbashir10/

Twitter: https://twitter.com/mubbashir100

💖 💪 🙅 🚩
mubbashir10
Mubbashir Mustafa

Posted on January 31, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related