Mubbashir Mustafa
Posted on January 31, 2022
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
For other OS, grab the relevant binary and install that
Verify the installation by running copilot -v
Step 3
Inside your app folder, run
copilot init
It will ask you to name your application, provide any name
Next, select the application type (for this tutorial I am selecting Load Balanced Web Service
Next, it will ask for the name of the service, provide any suitable name
If there are multiple Dockerfiles present, it will ask you to pick the desired one
It will begin the build process now
Once the build is ready, it will ask you if you would like to deploy your service to a test environment, select Yes
Wait for it to finish the process, once finished it will give you a URL to the service
Grab the URL and test it in a browser
Step 4
Now set up a pipeline for automated workflows (CI/CD)
Inside your app run
copilot pipeline init
git add copilot/pipeline.yml copilot/buildspec.yml copilot/.workspace && git commit -m "Adding pipeline artifacts" && git push
copilot pipeline update
Once the pipeline finishes, you can verify the changes by visiting the same URL again
Cleanup
To delete the app just run copilot app delete
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
Posted on January 31, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.