Terraform resources for HCP Consul Dedicated automation
In this tutorial collection you learned how to use the Terraform templates you can obtain from the HCP UI to deploy a demo application in a new HCP Consul Dedicated cluster.
This tutorial will give you some more details on the Terraform resources you used to manage your HCP Consul Dedicated cluster and to deploy your application.
- Terraform
hcp
provider - contains the resources and the data sources to interact with the HCP platform. - Terraform
hcp-aws-consul
module - demo module to deploy an example application on either EC2 or EKS.
Terraform hcp
provider
This is the main provider you want to use if you want to deploy and manage HCP resources. This provider contains the resources and the data sources to interact with the HCP platform.
HashiCorp Virtual Network (HVN)
Everything in HashiCorp Cloud Platform (HCP) starts with the HashiCorp Virtual Network (HVN).
HVNs enable you to deploy HashiCorp Cloud products without having to manage the networking details. They give you a simple setup for creating a network on AWS, in the region of your choice, and with the option to specify a CIDR range.
The hcp
provider permits you to create a new HVN using a module or to retrieve
information from an existing HVN using a data source. The latter is used in case
you want to deploy new resources in an existing HVN.
module
hcp_hvn
- The HVN resource allows you to create a HashiCorp Virtual Network in HCP.data source
hcp_hvn
- The HVN data source provides information about an existing HashiCorp Virtual Network.
HCP Consul Dedicated cluster
Once you have an HVN created and configured. HCP Consul Dedicated enables you to quickly deploy Consul clusters in AWS across various environments while offloading the administrative burden to the SRE experts at HashiCorp.
The hcp
provider permits you to create a new HCP Consul Dedicated cluster using a module
or to retrieve information from an existing cluster using a data source. The
latter is used in case you want to use an existing HCP Consul Dedicated deployment and to
connect clients to it.
module
hcp_consul_cluster
- The Consul cluster resource allows you to manage an HCP Consul Dedicated cluster.data source
hcp_consul_cluster
- The cluster data source provides information about an existing HCP Consul Dedicated cluster.
Network peering with your VPC
Creating a network peering from your HVN will allow you to connect and launch AWS resources to your HCP account. Peer your Amazon VPC with your HVN to enable resource access. After creating, you will need to accept the peering request and set up your VPC’s security groups and routing table on your AWS account.
The Amazon VPC can be managed with the AWS provider
while the peering can be managed using some resources available in the hcp
provider.
resource
hcp_aws_network_peering
- The AWS network peering resource allows you to manage a network peering between an HVN and a peer AWS VPC.
resource
hcp_hvn_route
- The HVN route resource allows you to manage an HVN route.
Terraform hcp-aws-consul
module
Once you have fully deployed HCP Consul Dedicated, you need to deploy Consul clients inside of the peered VPC to fully access your Consul features.
To help you deploy Consul clients, we have created a Terraform module
hcp-aws-consul
that provides some test scenarios that you can use as a blueprint for your
deployments.
Also called the root module, it takes as input a HVN, an AWS VPC, a list of AWS routing tables that need to route to the HVN CIDR block, and a list of AWS security groups to allow inbound Consul traffic.
Alongside the hcp-aws-consul
module, some examples and submodules represent
specific example scenarios that you can try directly without any customization
and that you can use as a starting point for customizing the deploy for your
specific needs.
Note
These modules are only intended for demonstration purposes. While the Consul clients will be deployed secure-by-default, the limited configuration options presented by the module are to aid a user in quickly getting started.
Resources for EC2
submodule
hcp-ec2-client
- Install Consul and Nomad on an EC2 instance, connect to the HCP Consul Dedicated cluster and use Nomad to deploy a demo application.example
hcp-ec2-demo
- Use thehcp-ec2-client
submodule to create EC2 virtual machines and run Consul clients.
Resources for EKS
submodule
hcp-eks-client
- Install the Consul Helm chart on a provided Kubernetes cluster and deploy a demo application on the cluster.example
hcp-eks-demo
- Use thehcp-eks-client
submodule to deploy an EKS cluster to run Consul clients and deploys a demo application on the cluster.
Next steps
In this tutorial you got an overview of the available Terraform resources used to manage your HCP Consul Dedicated cluster and workload.
If you encounter any issues, please contact the HCP team at support.hashicorp.com.