A Vault cluster using Consul backend, provisioned with Terraform.
$ brew install terraform consul-backinator cmake
$ cp terraform.tfvars.example terraform.tfvars
To provision you need to fill in the details in terraform.tfvars
aws_access_key
It must belong to a user with administrator privileges under your AWS accountaws_secret_key
The secret key for the above useraws_account
A string that helps you to identify the provisioned resources. We use AWS account nameprefix
We useprod
in production, etc. You can test your provisioning process by changing thisdomain
The internal domain name for the instancesvault_address
FQDN where your Vault service will be reachable from the internetssh_public_key
The public key that will be used to access the instances
$ terraform plan \
-out terraform.tfplan
$ terraform apply \
terraform.tfplan
$ make init
$ make unseal # three times by default
View the infrastructure diagram.
Upgrading Consul or Vault is simple. Just change the version in variables.tf
, then upgrade instances one-by-one.
$ make backup # To backup Consul
$ terraform plan \
-target "aws_instance.vault[0]" \
-target "aws_route53_record.vault[0]" \
-target "aws_elb.vault" \
-out terraform.tfplan
$ terraform apply \
-target "aws_instance.vault[0]" \
-target "aws_route53_record.vault[0]" \
-target "aws_elb.vault" \
terraform.tfplan
$ make cleanup # Cleanup failed Consul peers
$ make unseal # three times by default
$ make healthcheck
As an additional step - when you are about to upgrade the active
Vault node - you could make it giving up its leader position before recreating the instance. It'll take ~10 seconds on the ELB for the new active
node to appear. Skipping this step would make the new leader appear in ~60 seconds.
$ make bastion
$ ssh <leader>
$ vault auth
$ vault step-down
Issue make
to see.
- Using official Consul docker image.
- Using official Vault docker image.
- Uses a self-signed certificate by default for HTTPS access through loadbalancer. This is not secure. Do not store sensitive data in your repository.
- CoreOS version is hardcoded and update strategy is set to
off
. Upgrade manually.
- Tests
MIT License © Domonkos Cinke