HashiCorp Cloud Platform (HCP) Consul is a fully managed Service Mesh as a Service (SMaaS) version of Consul. While you can deploy a HCP Consul server and connect the consul clients in your VPC manually or using Terraform, using Terraform allows you to reduce the time to deployment significantly.
To help you get started, the HCP Consul UI uses the recently released HCP AWS Terraform modules and generates a single file based on your inputs with all the Terraform configuration . With this configuration, you can complete a development environment and launch an example application, composed by five different microservices, in less than 30 min.
To run these scenarios you do not need expert knowledge of Terraform.
You can get an overview of the tutorial collection by watching this video.
»Prerequisites
To complete tutorials in this collection you will need the following.
Basic command line access
The Terraform v1.0.0+ installed
Git installed
Admin access to the HashiCorp Cloud Platform (HCP) Consul portal
Note: HCP
Admin
access is necessary to create the Service Principal credentials used by Terraform to interact with HCP. If you already have a Service Principal key and client id provided by your admin, you only requireContributor
access. If you are anAdmin
and would like to create a Service Principal, check Deploy HCP Consul with Terraform tutorial for instructions on how to create a Service Principal.An AWS account and AWS Access Credentials
»HCP Consul deployment steps
This section shows the logical steps required to create a new HCP Consul cluster and to deploy services in the service mesh.
Note: There are some extra resources under each step's picture to learn more about the step. You can review the existing Terraform resources available to perform the step or get a list of tutorials that perform the step at different levels of automation.
The following image depicts a generic architectural diagram of a deployed HCP Consul cluster peered to a VPC in AWS with Consul client running and services deployed in the service mesh.
»End-to-end scenarios
All the steps listed above can be automated using Terraform. The Terraform resources tab under each step shows the Terraform resources used at that stage for the deploy.
The modules have been integrated with the HCP UI to provide you with a fast way to start deploying your applications with HCP Consul.
Get started from the Overview page and click on Deploy with Terraform
The link will help you customize a Terraform template to adapt to multiple scenarios. The following sections will guide you through the available resources to use the templates you can download from HCP.
The Terraform configuration that is going to be generated for you will enable you to
- Complete a deployment from steps 1 to 5 as mentioned in the deployments steps section.
- Run a demo application with five microservices.
»EKS example scenarios
A common use case is to deploy your application in a Kubernetes cluster and then use Consul as the service mesh provider.
In the Deploy HCP Consul with EKS using Terraform tutorial you will learn how to deploy a HCP Consul cluster and to deploy a sample application on an EKS cluster that will be created on the same operation.
The tutorial will show you how to use an existing VPC for your test, in case you don't want to create a new one.
»EC2 example scenarios
Another common use case is to deploy your applications in a set of virtual machines and then make them communicate using Consul as the service mesh provider.
In the Deploy HCP Consul with EC2 using Terraform tutorial you will learn how to deploy a HCP Consul cluster and to deploy a sample application on EC2 instances that will be created on the same operation.
The tutorial will show you how to use an existing VPC for your test, in case you don't want to create a new one.
»ECS example scenarios
Consul is also able to integrate with AWS ECS to help manage your serverless applications.
In the Deploy HCP Consul with ECS using Terraform tutorial you will learn how to deploy a HCP Consul cluster and to deploy a sample application on an ECS cluster that will be created on the same operation.
The tutorial will show you how to use an existing VPC for your test, in case you don't want to create a new one.
»Customize Terraform code to use existing resources
The previous example scenarios are an ideal subset of use-cases where you deploy HCP Consul and your workload simultaneously using Terraform.
Sometimes the situation can be more complex so we prepared a list of examples that could match your scenario and help you leverage HCP Consul fully, no matter your starting point.
- Create a HCP Consul cluster for an existing EKS run time
- Serverless Consul service mesh with ECS and HCP
»Deep dive into available modules
The examples in this tutorial collection are designed to provide users with no Terraform expertise a way to quickly deploy services in HCP Consul and test the platform. The modules are not intended for production use but you can use the provided code and modify it to adapt it to your specific use case.
If you want to learn more about the different modules used in this collection, check out the Terraform modules for HCP Consul automation tutorial to get some more details on the Terraform providers and modules used in these tutorials.
»Next steps
In this tutorial you got an overview on the steps required to deploy HCP Consul and to connect it to your workload in AWS. You got an introduction on the available Terraform resources to interact with HCP and deploy a Consul datacenter on different resources on AWS.
In the next tutorial you will use Terraform to deploy a demo application on AWK EKS using HCP Consul as your service mesh.
If you encounter any issues, please contact the HCP team at support.hashicorp.com.