Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconroot-example
file-type-iconvault-agent
file-type-iconvault-auto-unseal
file-type-iconvault-cluster-private
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconuser-data-consul.sh
file-type-iconuser-data-vault.sh
file-type-iconvariables.tf
file-type-iconvault-consul-ami
file-type-iconvault-ec2-auth
file-type-iconvault-examples-helper
file-type-iconvault-iam-auth
file-type-iconvault-s3-backend
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-iconroot-example
file-type-iconvault-agent
file-type-iconvault-auto-unseal
file-type-iconvault-cluster-private
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconuser-data-consul.sh
file-type-iconuser-data-vault.sh
file-type-iconvariables.tf
file-type-iconvault-consul-ami
file-type-iconvault-ec2-auth
file-type-iconvault-examples-helper
file-type-iconvault-iam-auth
file-type-iconvault-s3-backend
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 Vault

HashiCorp Vault

Deploy a Vault cluster. Supports automatic bootstrapping, Consul and S3 backends, self-signed TLS certificates, and auto healing.

Code Preview

Preview the Code

mobile file icon

README.md

down

Private Vault Cluster Example

This folder shows an example of Terraform code to deploy a Vault cluster in AWS using the vault-cluster module. The Vault cluster uses Consul as a storage backend, so this example also deploys a separate Consul server cluster using the consul-cluster module from the Consul AWS Module.

This example creates a private Vault cluster, which is private in the sense that the EC2 Instances are not fronted by a load balancer, as is the case in the Vault Public Example. Keep in mind that if the Vault nodes are deployed to public subnets (i.e. subnets that have a route to the public Internet), this "private" cluster will still be accessible from the public Internet.

Each of the servers in this example has Dnsmasq installed (via the install-dnsmasq module) or setup-systemd-resolved (in the case Ubuntu of 18.04) which allows it to use the Consul server cluster for service discovery and thereby access Vault via DNS using the domain name vault.service.consul. For an example of a Vault cluster that is publicly accessible, see the root example.

Vault architecture

You will need to create an Amazon Machine Image (AMI) that has Vault and Consul installed, which you can do using the vault-consul-ami example).

For more info on how the Vault cluster works, check out the vault-cluster documentation.

Note: To keep this example as simple to deploy and test as possible, it deploys the Vault cluster into your default VPC and default subnets, all of which are publicly accessible. This is OK for learning and experimenting, but for production usage, we strongly recommend deploying the Vault cluster into the private subnets of a custom VPC.

Quick start

To deploy a Vault Cluster:

  1. git clone this repo to your computer.
  2. Optional: build a Vault and Consul AMI. See the vault-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 vault-examples-helper.sh script to print out the IP addresses of the Vault servers and some example commands you can run to interact with the cluster: ../vault-examples-helper/vault-examples-helper.sh.

To see how to connect to the Vault cluster, initialize it, and start reading and writing secrets, head over to the How do you use the Vault cluster? docs.

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?