Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconconsul-ami
file-type-iconconsul-examples-helper
file-type-iconexample-with-custom-asg-role
file-type-iconexample-with-encryption
file-type-iconroot-example
file-type-iconREADME.md
file-type-iconuser-data-client.sh
file-type-iconuser-data-server.sh
file-type-iconREADME.md
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf

Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconconsul-ami
file-type-iconconsul-examples-helper
file-type-iconexample-with-custom-asg-role
file-type-iconexample-with-encryption
file-type-iconroot-example
file-type-iconREADME.md
file-type-iconuser-data-client.sh
file-type-iconuser-data-server.sh
file-type-iconREADME.md
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
HashiCorp Consul

HashiCorp Consul

Deploy a Consul cluster. Supports automatic bootstrapping, DNS, Consul UI, and auto healing.

Code Preview

Preview the Code

mobile file icon

README.md

down

Consul Cluster Example

This folder shows an example of Terraform code that uses the consul-cluster module to deploy a Consul cluster in AWS. The cluster consists of two Auto Scaling Groups (ASGs): one with a small number of Consul server nodes, which are responsible for being part of the consensus quorum, and one with a larger number of client nodes, which would typically run alongside your apps:

Consul architecture

You will need to create an Amazon Machine Image (AMI) that has Consul installed, which you can do using the consul-ami example). Note that to keep this example simple, both the server ASG and client ASG are running the exact same AMI. In real-world usage, you'd probably have multiple client ASGs, and each of those ASGs would run a different AMI that has the Consul agent installed alongside your apps.

For more info on how the Consul cluster works, check out the consul-cluster documentation.

Quick start

To deploy a Consul Cluster:

  1. git clone this repo to your computer.
  2. Optional: build a Consul AMI. See the consul-ami example documentation for instructions. Make sure to note down the ID of the AMI.
  3. Install Terraform.
  4. Open variables.tf, set the environment variables specified at the top of the file, and fill in any other variables that don't have a default. If you built a custom AMI, put the AMI ID into the ami_id variable. Otherwise, one of our public example AMIs will be used by default. These AMIs are great for learning/experimenting, but are NOT recommended for production use.
  5. Run terraform init.
  6. Run terraform apply.
  7. Run the consul-examples-helper.sh script to print out the IP addresses of the Consul servers and some example commands you can run to interact with the cluster: ../consul-examples-helper/consul-examples-helper.sh.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?