Skip to content

hashicorp/terraform-provider-hcp

Folders and files

NameName
Last commit message
Last commit date
Mar 14, 2025
Feb 20, 2025
Feb 21, 2023
Jan 7, 2021
Nov 4, 2024
Apr 16, 2024
Jul 7, 2021
Mar 14, 2025
Mar 14, 2025
Mar 14, 2025
Feb 21, 2023
Mar 14, 2025
Feb 21, 2023
Feb 21, 2023
Feb 21, 2023
Sep 21, 2022
Jan 17, 2025
Sep 13, 2024
Nov 18, 2024
Feb 27, 2025
Feb 3, 2025
Oct 13, 2022
Oct 30, 2023
Feb 10, 2025
Feb 10, 2025
Jul 31, 2023
Feb 12, 2021
Feb 14, 2025
Oct 19, 2023

HashiCorp Cloud Platform logo

HashiCorp Cloud Platform (HCP) Terraform Provider

Available in the Terraform Registry.

The HashiCorp Cloud Platform (HCP) Terraform Provider is a plugin for Terraform that allows for the full lifecycle management of HCP resources. This provider is maintained internally by the HashiCorp Cloud Services team.

Requirements

Using the Provider

See the HashiCorp Cloud Platform (HCP) Provider documentation to get started using the provider.

Contributing

See the contributing directory for more developer documentation.

Design

See the design for documents capturing certain key design decisions made for this provider as a platform.

Example

Below is a complex example that creates a HashiCorp Virtual Network (HVN), an HCP Consul cluster within that HVN, and peers the HVN to an AWS VPC.

// Configure the provider
provider "hcp" {}

provider "aws" {
  region = "us-west-2"
}

// Create a HashiCorp Virtual Network (HVN).
resource "hcp_hvn" "example" {
  hvn_id         = "hvn"
  cloud_provider = "aws"
  region         = "us-west-2"
  cidr_block     = "172.25.16.0/20"
}

// Create an HCP Consul cluster within the HVN.
resource "hcp_consul_cluster" "example" {
  hvn_id         = hcp_hvn.example.hvn_id
  cluster_id     = "consul-cluster"
  tier           = "development"
}

// If you have not already, create a VPC within your AWS account that will
// contain the workloads you want to connect to your HCP Consul cluster.
// Make sure the CIDR block of the peer VPC does not overlap with the CIDR
// of the HVN.
resource "aws_vpc" "peer" {
  cidr_block = "10.220.0.0/16"
}

// Create an HCP network peering to peer your HVN with your AWS VPC.
resource "hcp_aws_network_peering" "example" {
  peering_id          = "peer-id"
  hvn_id              = hcp_hvn.example.hvn_id
  peer_vpc_id         = aws_vpc.peer.id
  peer_account_id     = aws_vpc.peer.owner_id
  peer_vpc_region     = "us-west-2"
}

// Create an HVN route that targets your HCP network peering and matches your AWS VPC's CIDR block.
resource "hcp_hvn_route" "example" {
  hvn_link         = hcp_hvn.example.self_link
  hvn_route_id     = "peer-route-id"
  destination_cidr = aws_vpc.peer.cidr_block
  target_link      = hcp_aws_network_peering.example.self_link
}

// Accept the VPC peering within your AWS account.
resource "aws_vpc_peering_connection_accepter" "peer" {
  vpc_peering_connection_id = hcp_aws_network_peering.example.provider_peering_id
  auto_accept               = true
}

// Create a Vault cluster within the HVN.
resource "hcp_vault_cluster" "example" {
  cluster_id = "vault-cluster"
  hvn_id     = hcp_hvn.example.hvn_id
}