/terraform-hcp-consul-cluster

Terraform module for an HCP Consul cluster

Primary LanguageHCLMIT LicenseMIT

HCP Consul Cluster Terraform Module

Terraform module which provisions a simple HCP Consul cluster for demonstration purposes. Only a subset of the available configuration options are exposed.

By default a HashiCorp Virtual Network is also created, unless create_hvn = false and the hvn_id of an existing HVN is supplied.

Prerequisites:

  • An HCP organization
  • HCP "Contributor" credentials set as environment variables HCP_CLIENT_ID and HCP_CLIENT_SECRET (see the HCP provider authentication guide). Optionally specify HCP_PROJECT_ID. If not included, the oldest project in the organization will be used.
    • If using a project-level service principal, HCP_PROJECT_ID is required

Requirements

Name Version
terraform >= 1.2
hcp >= 0.57

Providers

Name Version
hcp >= 0.57

Modules

No modules.

Resources

Name Type
hcp_consul_cluster.this resource
hcp_consul_cluster_root_token.root resource
hcp_hvn.this resource

Inputs

Name Description Type Default Required
cidr_block CIDR block for the HVN. string "172.25.16.0/20" no
cloud_provider Cloud provider where the HVN and Consul cluster will be located. Only used if create_hvn = true. string "aws" no
consul_cluster_id ID for the Consul cluster. If left blank, an ID will be generated for you. string "" no
create_hvn Whether to create a new HVN or use an existing one. bool true no
hvn_id ID of the HVN. If create_hvn = false, this must be set to an existing HVN ID. If left blank and create_hvn = true, an ID will be generated for you. string "" no
min_consul_version The minimum Consul patch version of the cluster. If not specified, it is defaulted to the version that is currently recommended by HCP. string null no
prefix This prefix will be used to generate unique resource names. string n/a yes
public_endpoint Whether the Consul cluster should have a public endpoint. If false, you will need to set up HVN peering to reach the cluster. bool false no
region Region where the HVN and Consul cluster will be located. Only used if create_hvn = true. string "us-east-1" no
tier Sizing tier of the Consul cluster. string "development" no

Outputs

Name Description
consul_ca_file Cluster CA file encoded as a Base64 string.
consul_cluster_id ID of the HCP Consul cluster.
consul_cluster_root_token Secret ID of the root ACL token for the HCP Consul cluster.
consul_config_file Cluster config encoded as a Base64 string.
consul_private_endpoint_url Private endpoint of the HCP Consul cluster.
consul_public_endpoint_url Public endpoint of the HCP Consul cluster.
consul_version Version of the Consul cluster.
hvn_id ID of the HashiCorp Virtual Network (HVN).