With an increasing number of independent applications and application features, it is very essential that they are released with the least time to market possible. Copilot CLI is a huge step in that direction, a rename of the ECS CLI tool created for being effective and simple, facilitates the usage of CI/CD pipeline, allowing organizations to leverage its full potential without the requirement to know in-depth about CI/CD and the required AWS services to achieve it.
Why use AWS Copilot CLI?
Co-pilot is an opinionated tool, opinionated because built into this CLI is all the best practices used at AWS, those practices that AWS suggests for all its users ensuring reliability, security, and fault-tolerance. The beauty of Copilot CLI is that it will build the platform and connect all the resources together by itself, we just need to define the application.
Benefits of AWS Copilot CLI
- Focus on Architecture, not infrastructure
-
-
- With Copilot CLI you spend time on developing your application and enhancing it, rather than creating the architecture where your application shall run, as copilot does all the heavy lifting for you.
-
- Simple and powerful config
- Copilot provides you a customizable simple manifest file that you can tweak to meet the requirements for your application, such as CPU & Memory, or the number of tasks you want to run for your application.
Copilot Features
- Develop – All you require is a Dockerfile to get started with, and copilot will create your infrastructure using that.
- Release – With Copilot you can provision multiple environments such as prod and test environemnts, maybe in one single account or multiple account, and implementing CI/CD using Copilot you can release your application to these environments.
- Operate – Each service in your application has its independent set of logs, metrics and alarms, and copilot collates all of that in a single place for you deep dive into all of that.
Agenda of the blog
Introduction to AWS Copilot CLI, understanding the Copliot workflow and automating application release using CI/CD pipeline with integration to GitHub created using Copilot.
Prerequisites
An AWS account.
An IAM user with Admin access.
AWS CLI configured with the creds of the created IAM user.
How to Install Copilot?
https://aws.github.io/copilot-cli/docs/getting-started/install/
Meet The Application
Dockerfile
FROM submar1n3/webimage:v6
EXPOSE 80
COPY index.html /usr/local/apache2/htdocs/index.html
Index.html
Hello World!
To start with, it is best to go through the documentation by just typing
copilot docs in the terminal.
Initializing an application using copilot, creating an environment and deploying a service to that env
copilot app init
copilot env init
copilot svc init
copilot svc deploy –name svcname –env envname
At the end of this step, you will see a service url on the terminal that will take you to the deployed application.
This process is simple and can be sufficient for a single application, but in the scenario where you have microservices architecture enabled with multiple applications, this approach will no longer suffice that requirement.
Automate the application release across our environment
We have multiple options for automating the application release such as multiple developers working on the same project can deploy their own svc using copilot, but in that scenario there is a chance of the application breaking due to a new svc deploy by one of the developers that did not work, also we can have a scenario where only one person deploys the service using copilot after the code is reviewed but that will surely create a bottleneck for the application release. We can connect both approaches and create a single pipeline where multiple developers can deploy their services using copilot.
copilot pipeline init
In the auto-generated buildspec.yml, pipeline.yml files in the copilot directory you can do custom changes according to your requirement. Also, you can add integration tests into your buildspec.yml file. In this blog we will do not have any unit or integration test setup for our application.
git add –A
git commit
git push
copilot pipeline update
Now you shall receive a link once you run this command, asking you to authenticate your GitHub account for the pipeline to use it.
Open the link in a browser and go through the mentioned steps
- Update pending connection
- Install a new app
- Only select Repositories
- Select the repo you want to use with your pipeline
- Connect to GitHub.
Monitor the status of your pipeline
copilot pipeline status
Our pipeline is up and running, you can access the deployed application using the environment url displayed by running
copilot svc show
Now you can do incremental changes to your code and every time you push the code to your GitHub Repository, your pipeline will be triggered.
Cleaning the Copilot Environment
copilot app delete
Conclusion
In this blog we demonstrated AWS Copilot CLI tool and its usage and on how to implement CI/CD pipeline for your application using Copilot.