Pilot your containers like a boss with AWS Copilot!
Getting started with AWS Copilot
Copilot my friend
Everyone loves command line right?
Ok, at least if you regularly work with automation, pipelines, security... you do.
Everyone should love command lines!
It's the way to go to automate any strategic or boring task, removing the human factor from the equation and minimizing the error margin.
In this article, I will introduce you to AWS Copilot, and I'm sure you are going to become best friends in an instant!
Then we will prepare you to start the journey with a quick demo. Demos are like breakfast before hiking, right?
It prepares you just enough to be motivated enough to get started...
So, what are we waiting to prepare our hike?
What is Copilot?
You might (or might not) know about Amazon Elastic Compute Service (ECS), the AWS managed container orchestration system.
Thanks to Amazon ECS, running containerized application in a secure, observable and integrated way became really easy.
The idea of Amazon Copilot is to change the way you think about ECS. It's like going one step further...
No more manual management or lower-level infrastructure, with Copilot, you only think about your application.
We could say it's something like "ECS architecture design patterns and best practices" As A Service.
The only thing you need to do is to provide a container and Copilot will deploy and operate it following the ECS best practices to provide high availability, configuration and state of the art infrastructure.
Copilot can even handle the deployment pipeline for you.
How can you quickly start?
- Install Copilot
Just install Copilot for your favourite OS from here
- Install Docker
Copilot will use docker to package the application.
You will find all the installation details here
- Configure your credentials
If you don't use it already, install the AWS CLI and configure your credentials using
Deploy a demo app
AWS prepared something for you and me...
git clone https://github.com/aws-samples/amazon-ecs-cli-sample-app.git demo-app
This repository contains a ready-to-deploy application to quickly use copilot.
One more step and you will be done:
Answer the questions: demo, Load Balanced Web Service, api, Dockerfile, 80.
You could also pass all those values as parameter but Copilot is kind enough to ask you if you forgot to give the information in the first time.
As Copilot is able to look inside your code (what a clever tool, isn't it?), it might be able to find the Dockerfile by itself (and port too).
Then choose to deploy a test environment.
When the deployment has completed, you will be able to check it.
Tips: You might use some commands from the "some helpful commands" section...
Here is what Copilot is doing underneath:
You know what's great news?
You don't even need to know how to manage any of the steps into this schema. Copilot is doing it for you, taking all the responsibilities.
Isn't this cool?
In the mean time, maybe at some point you will want to clean up the environment:
copilot app delete
Super easy right?
Some helpful commands
To get familiar with the tool, try the following commands:
(You didn't think I was going to do all the work for you, right?)
copilot app ls # list the applications managed by copilot copilot app show # describe environments and services copilot env ls # list the environments copilot svc show # describe service and will gather information to present it in one centralized place in the console copilot svc ls # list services copilot svc logs # show service logs copilot svc status # show service status
Beside this little selection, feel free to launch
copilot --help to get more details and
copilot docs to access the online documentation in your browser (very useful to dive deeper into the details)
Tailor made deployments
Copilot offers you some really useful built-in patterns to help you manage your containerized application.
copilot svc deploy is performing deployment of updates to the ECS clusters.
copilot svc exec allows you to securely run commands into the containers tasks. This is especially useful for troubleshooting.
Infra-As-Code passionate or just curious?
AWS Copilot didn't forgot you:
copilot svc package will show you the cloud formation used to deploy the infrastructure. You can then explore it and even use it outside of Copilot context.
This way, your are not bound to AWS Copilot, you just leave whenever you want.
Tips: The manifest.yml file (
copilot/<your service or job name>/manifest.yml) is a copilot-generated file converted to Cloudformation format, describing the architecture of the service.
Pipeline my love
When I said Copilot CLI was helping implementing good practices and pattern, I also though about CI/CD...
You can indeed build a pipeline based on AWS CodePipeline, AWS CodeBuild AWS CodeDeploy and GitHub.
copilot pipeline init
This will initialize some files to prepare the pipeline deployment.
If you specify some arguments, Copilot will create two files:
pipeline.yml: configuration options
buildspec.yml: the steps to deploy through AWS CodePipeline
# Some arguments you can give to copilot pipeline init command --github-url --github-access-token --git-branch --environments
Then you push these files to the repository and run the following:
copilot pipeline update
That's it! Your pipeline will be created into CodePipeline.
Tips: To add steps (testing) and get more details, have a look at the Copilot documentation
The latest cool features
AWS Copilot is still evolving quickly and the team just release some new features.
HTTP to HTTPS automated redirection for Load Balanced Services with domain name
Aurora Serverless support
NAT Gateway support for private workloads
Volume sharing between containers
More features are currently under development, check out the public roadmap here
Copilot will be your friend if you want to easily deploy your containerized application in a production-ready way.
Think about it again...
You are a few commands away from having an "Architecture patterns as a service" tool!
Be aware that Copilot is open source and that the repository can be found here. The team is sometimes releasing new versions several times per month and you are free to participate by opening issues or launching pull requests.