AWS Copilot - launch and manage containerized applications quickly 🐳
Tags: aws, docker, beginners, node
Published: 2022-01-31 01:10:33

---
series: Containers on AWS
---
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](https://github.com/mubbashir10/aws-proton-nodejs-sample) 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](https://github.com/aws/copilot-cli/issues/1345). 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](https://aws.github.io/copilot-cli/docs/getting-started/install/)

Verify the installation by running `copilot -v`

![AWS Copilot Version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gncytntytre1kojb43az.png)


#### Step 3
Inside your app folder, run 
```
copilot init
```
It will ask you to name your application, provide any name

![AWS Copilot Init](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvk326435c1zoferjkaa.png)

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


![AWS Copilot service type selection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/378xk345yr1xn9mk7ja5.png)
 

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

![AWS Copilot service name selection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqk0baxody7i703mru3r.png)
 

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

![AWS Copilot Dockerfile suggestion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0e6ovvde10qmsxkq8w71.png)

It will begin the build process now

![AWS Copilot Init Completed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phd39t8ieo12h9op4kxw.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3795anl2v1p18iazcmq7.png)
 

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

![AWS Copilot Service Deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zga9xhlihxwspmocny0k.png) 

Grab the URL and test it in a browser
![AWS Copilot live service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7l7r62miei4umrglbldr.png)


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

Inside your app run 

```
copilot pipeline init
```
![AWS Copilot pipeline](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/10g026499e44kw2ttkzr.png)

``` 
git add copilot/pipeline.yml copilot/buildspec.yml copilot/.workspace && git commit -m "Adding pipeline artifacts" && git push
```
![AWS Copilot CI/CD](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfsm7bhqo1j56njicsol.png)
 
```
copilot pipeline update
```
![AWS Copilot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i6zo6skieaofmu8ahi34.png)

Once the pipeline finishes, you can verify the changes by visiting the same URL again
![AWS Copilot CI/CD Changes Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5duv64syan144g6uz0ov.png)

#### Cleanup
To delete the app just run `copilot app delete`
![Delete AWS Copilot App](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fg2xh1en91jsxquflrv.png)

---
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](https://dev.to/mubbashir10/deploy-microservices-on-aws-ecs-fargate-serverless-16el).

---
Let's connect: 

Linkedin: [https://www.linkedin.com/in/mubbashir10/](https://www.linkedin.com/in/mubbashir10/) 

Twitter: [https://twitter.com/mubbashir100](https://twitter.com/mubbashir100)