Deploy an Application to AWS Elastic Container Service
Warning
This content is part of the legacy version of Waypoint that is no longer actively maintained. For additional information on the new vision of Waypoint, check out this blog post and the HCP Waypoint documentation.
With Waypoint, it is quick and easy to deploy and release applications on AWS Elastic Container Service (ECS).
In this tutorial, you will use Waypoint's AWS ECS plugin to build a container image containing a NodeJS application, push it to a Elastic Container Registry (ECR) repository, then deploy and update the application to ECS.
Prerequisites
You will need to install waypoint
binary locally, clone the examples repository (detailed in the next section), set up your AWS credentials, and create an Elastic Container Registry.
You will be most comfortable if you have already used Waypoint to do a local deployment with our Get Started tutorials.
Optional: Provision a Kubernetes cluster and install the Waypoint server to Kubernetes in order to unlock all Waypoint functionality (including application logs
, exec
, and ui
access).
Clone the examples repository
The code for this tutorial is in the hashicorp/waypoint-examples
repository. Clone the repository with git.
Change into the subdirectory for the AWS ECS project. This project uses NodeJS but the following instructions will work with any language that can be built with a cloud native buildpack.
Install the Waypoint server
The Waypoint server must be installed. You may install it locally which requires fewer steps but limits the functionality of some Waypoint commands. Or, install to a remote Kubernetes cluster for full functionality (including the logs
, exec
, and ui
commands).
You can run the Waypoint server locally in Docker in order to achieve a minimal deployment of your applications on ECS.
Note
A local server used with a remote deployment only supports limited functionality. The logs
, exec
, and other commands require a remote server with a remote deployment.
Install the Waypoint server to your local Docker instance.
If you run into any errors, see the troubleshooting page which has instructions for resetting the Waypoint server in Docker.
Explore waypoint.hcl
Open the
waypoint.hcl
file. In this section, you will explore the build
and deploy
steps for this
project.
The waypoint.hcl
file uses the aws-ecr
registry plugin during the build
stage. The aws-ecr
plugin uses your AWS credentials and internally builds the correct URL to the AWS API.
It is also possible to configure this manually with the docker
plugin. Other
configuration options are listed in the plugin
documentation.
Use the aws-ecs
plugin for the deploy
stage. You can specify the region
, memory
, and cpu
as well as a count
of how many instances to launch or a log_group
to store the logs in a CloudWatch log group.
See the plugin documentation for other configuration options.
Note
When using this configuration, Waypoint will automatically provision an ECS cluster that uses Fargate. Fargate instances are temporary and will only run while they are being actively used. Read the plugin documentation if you prefer to use permanent EC2 instances in an existing ECS cluster instead.
Initialize Waypoint
Initialize the project with the init
command.
Read the troubleshooting page if you run into any errors.
Build, deploy, and release the application
Deploy the application with up
.
Note
This may take a few minutes to execute, especially if this is the first time that you push the image to the registry.
Visit the Release URL or the Deployment URL to view the application running on ECS.
You can visit the ECS console to view the server side of the cluster.
The cluster also lists individual tasks.
Destroy the instance
To deprovision the container, run destroy
.
If there is an error, try again after a few seconds.
Note
The destroy
command will not delete container images in the registry or the ECS cluster itself. Visit the ECR console to manually delete the entire registry or individual container images.
Next steps
Learn more about Waypoint by following along with the other tutorials for Azure, Google Cloud, and others, or read the documentation for other Waypoint plugins.