This module sets up a Vault cluster that can span 2 AWS regions. It makes use of the following AWS features:
- AWS DynamodDB global tables
- AWS SecretManager global replication
- AWS KMS cross region replicas
- Cross region VPC peering
By default resources are replicated in another region to act as a DR plan. It is possible to not run Vault instances on the other region but just keep the resources replicated.
Vault backend use DynamodDB plugins which allow HA for storage and nodes.
This module generates a pki to enable full end to end encryption into the vault instances. Certificates for vault are generated at startup on the instances and all the cluster internal communication are done with TLS
To allow end to end TLS, network load balancer are used in TCP mode. This module supports 2 NLB per region, 1 internal and 1 external.
Health Check by default are done with TCP check, this allow to use the Vault with TLS Client cert verification enabled. This also improve failover but route randomly the Vault request to any node, which then in turn forwards to the cluster leader. This generate east-west traffic across AZ and VPC Peering.
Health checks can also use HTTPS if vault client cert verification is disabled. 2
modes are availabled via the variable vault_routing_policy
:
all
: HTTPS healthcheck with all nodeHealthy
leader-only
: HTTPS healthcehck with only leaderHealthy
When vault_tls_require_and_verify_client_cert
is set, health checks default to TCP.
Support for private and public hosted zone for split horizon DNS. Register automatically the NLB as alias and sets up health check for DNS failover in case an AWS region is not available.
VPC peering between the 2 provided VPC is enabled by default, if VPCs are
already peered it can be disable with vpc_peering_enabled=false
.
vpc_peering_enabled
should be turn to true only after the
VPC have been created, or use the -target
feature.
Pariticule build and maintain AMI on AWS region available by default. Please pen an issue if you need us to support another region.
Instances have SSM enable by default, no need for SSH keys.
Name | Version |
---|---|
terraform | ~> 1.3 |
aws | >= 5.0 |
Name | Version |
---|---|
aws | >= 5.0 |
aws.secondary | >= 5.0 |
Name | Source | Version |
---|---|---|
pki | particuleio/pki/tls | ~> 2.0 |
primary | ./modules/vault-region | n/a |
secondary | ./modules/vault-region | n/a |
secrets | particuleio/secretsmanager/aws | >= 1.2 |
Name | Description | Type | Default | Required |
---|---|---|---|---|
ami_name_regex | n/a | string |
null |
no |
ami_owners | n/a | list(string) |
[ |
no |
asg | n/a | any |
n/a | yes |
asg_defaults | n/a | any |
{ |
no |
asg_secondary | n/a | any |
n/a | yes |
cfssl_version | n/a | string |
"1.6.4" |
no |
existing_dynamodb_tables | use exising dynamodbs tables (useful for recovery) | object({ |
{} |
no |
existing_kms_seal_key_id | use existing kms unseal key (useful for recovery) | string |
"" |
no |
name_prefix | A name to prefix every created resource with | string |
n/a | yes |
nlb_defaults | n/a | any |
{ |
no |
nlbs | n/a | any |
{ |
no |
nlbs_secondary | n/a | any |
{ |
no |
route53_private_zone_name | n/a | string |
"" |
no |
route53_zone_name | n/a | string |
"" |
no |
tags | A map of tags to apply to all resources | map(string) |
{} |
no |
vault_additional_config | Additional content to include in the vault configuration file | string |
"" |
no |
vault_additional_userdata | Additional content to include in the cloud-init userdata for the EC2 instances | string |
"" |
no |
vault_api_address | The address that vault will be accessible at | string |
n/a | yes |
vault_cert_dir | The directory on the OS to store Vault certificates | string |
"/usr/local/etc/vault/tls" |
no |
vault_config_dir | The directory on the OS to store the Vault configuration | string |
"/usr/local/etc/vault" |
no |
vault_default_lease_ttl | n/a | string |
"192h" |
no |
vault_dns_domain | The DNS address that vault will be accessible at | string |
n/a | yes |
vault_max_lease_ttl | n/a | string |
"192h" |
no |
vault_pki_ca_config | n/a | any |
{} |
no |
vault_pki_client_certs | n/a | any |
{ |
no |
vault_prometheus_retention_time | n/a | string |
"6h" |
no |
vault_routing_policy | n/a | string |
"all" |
no |
vault_tls_min_version | n/a | string |
"tls12" |
no |
vault_tls_require_and_verify_client_cert | n/a | bool |
false |
no |
vault_version | n/a | string |
"1.14.2" |
no |
vpc_id | The ID of the VPC to use | string |
n/a | yes |
vpc_peering_enabled | n/a | bool |
true |
no |
vpc_secondary_id | The ID of the VPC to use | string |
n/a | yes |
Name | Description |
---|---|
dynamodb | n/a |
primary | n/a |
secondary | n/a |
secrets | n/a |
vault_dns_domain | n/a |
vault_pki | n/a |