Terraform module for connecting a HashiCorp Cloud Platform (HCP) Consul cluster to AWS.
This module connects a HashiCorp Virtual Network (HVN) with an AWS VPC, ensuring that all networking rules are in place to allow a Consul client to communicate with the HCP Consul servers. The module accomplishes this in four steps:
- Create and accept a peering connection between the HVN and VPC
- Create HVN routes that will direct HCP traffic to the CIDR ranges of the subnets.
- Create AWS routes for each AWS route table that will direct traffic to the HVN's own CIDR range.
- Create AWS ingress rules necessary for HCP Consul to communicate to Consul clients.
module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
hvn = hcp_hvn.main
vpc_id = "vpc-0daa4a0915f1857db"
subnet_ids = ["subnet-098e9eb4bdd582522", "subnet-198e9eb4bdd582522"]
route_table_ids = ["rtb-079170034b7a99118", "rtb-179170034b7a99118"]
# Optionally provide security_group_ids. A new security group will be created
# if none are provided.
security_group_ids = ["sg-0ba8d296a786e93c7"]
}
A number of examples are provided which will run the following setup:
- Create an AWS VPC and associated resources
- Create a HashiCorp Virtual Network (HVN)
- Peer the AWS VPC with the HVN
- Create a HCP Consul cluster
- Run Consul clients within the provisioned AWS VPC
- Run a demo application on the chosen AWS runtime
These examples allow you to easily research and demo HCP Consul.
- hcp-ec2-demo - Use EC2 virtual machines to run Consul clients.
- hcp-eks-demo - Provision and use an EKS cluster to run Consul clients.
To support these examples, a few submodules are provided as useful utilities, for learning and experimentation purposes.
- hcp-ec2-client - [For Testing Only]: installs Consul and runs Consul clients with EC2 virtual machines.
- hcp-eks-client - [For Testing Only]: installs the Consul Helm chart on the provided Kubernetes cluster.
- k8s-demo-app - [For Testing Only]: installs a demo application onto the Kubernetes cluster, using the Consul service mesh.
This code is released under the Mozilla Public License 2.0. Please see LICENSE for more details.