Skip to content

Instantly share code, notes, and snippets.

@thejohnny
Created April 6, 2022 15:32
Show Gist options
  • Save thejohnny/1cf284d4310886de8d5c42082ffdea08 to your computer and use it in GitHub Desktop.
Save thejohnny/1cf284d4310886de8d5c42082ffdea08 to your computer and use it in GitHub Desktop.
Terraform to create pair of HVNs, peering connection and pair of clusters with perf replication
terraform {
required_providers {
hcp = {
source = "hashicorp/hcp"
}
}
}
provider "hcp" {}
resource "hcp_hvn" "us_west_2" {
region = "us-west-2"
hvn_id = "us-west-2"
cloud_provider = "aws"
# The CIDR block value must end between /16 and /25
cidr_block = "172.25.20.0/22" # 1,024 addresses
}
resource "hcp_hvn" "us_east_1" {
region = "us-east-1"
hvn_id = "us-east-1"
cloud_provider = "aws"
# The CIDR block value must end between /16 and /25
cidr_block = "172.25.24.0/22" # 1,024 addresses
}
resource "hcp_hvn_peering_connection" "us_east_1_to_us_west_2" {
hvn_1 = hcp_hvn.us_east_1.self_link
hvn_2 = hcp_hvn.us_west_2.self_link
}
resource "hcp_vault_cluster" "us_east_1_plus" {
cluster_id = "aws-us-east-1-plus"
hvn_id = hcp_hvn.us_east_1.hvn_id
public_endpoint = true
tier = "plus_small"
timeouts {}
}
resource "hcp_vault_cluster" "us_west_2_plus" {
cluster_id = "aws-us-west-2-plus"
hvn_id = hcp_hvn.us_west_2.hvn_id
public_endpoint = true
tier = "plus_small"
# replication
primary_link = hcp_vault_cluster.us_east_1_plus.self_link
timeouts {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment