The AWS network peering resource allows you to manage a network peering between an HVN and a peer AWS VPC.
provider "aws" {
region = "us-west-2"
}
resource "hcp_hvn" "main" {
hvn_id = "main-hvn"
cloud_provider = "aws"
region = "us-west-2"
cidr_block = "172.25.16.0/20"
}
resource "aws_vpc" "peer" {
cidr_block = "172.31.0.0/16"
}
data "aws_arn" "peer" {
arn = aws_vpc.peer.arn
}
resource "hcp_aws_network_peering" "dev" {
hvn_id = hcp_hvn.main.hvn_id
peering_id = "dev"
peer_vpc_id = aws_vpc.peer.id
peer_account_id = aws_vpc.peer.owner_id
peer_vpc_region = data.aws_arn.peer.region
}
resource "hcp_hvn_route" "main-to-dev" {
hvn_link = hcp_hvn.main.self_link
hvn_route_id = "main-to-dev"
destination_cidr = "172.31.0.0/16"
target_link = hcp_aws_network_peering.dev.self_link
}
resource "aws_vpc_peering_connection_accepter" "peer" {
vpc_peering_connection_id = hcp_aws_network_peering.dev.provider_peering_id
auto_accept = true
}
hvn_id
(String) The ID of the HashiCorp Virtual Network (HVN).peer_account_id
(String) The account ID of the peer VPC in AWS.peer_vpc_id
(String) The ID of the peer VPC in AWS.peer_vpc_region
(String) The region of the peer VPC in AWS.peering_id
(String) The ID of the network peering.project_id
(String) The ID of the HCP project where the network peering is located. Always matches the HVN's project.
If not specified, the project specified in the HCP Provider config block will be used, if configured.
If a project is not configured in the HCP Provider config block, the oldest project in the organization will be used.timeouts
(Block, Optional) (see below for nested schema)created_at
(String) The time that the network peering was created.expires_at
(String) The time after which the network peering will be considered expired if it hasn't transitioned into ACCEPTED
or ACTIVE
state.id
(String) The ID of this resource.organization_id
(String) The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.provider_peering_id
(String) The peering connection ID used by AWS.self_link
(String) A unique URL identifying the network peering.state
(String) The state of the network peering.timeouts
Optional:
create
(String)default
(String)delete
(String)Import is supported using the following syntax:
# Using an explicit project ID, the import ID is:
# {project_id}:{hvn_id}:{peering_id}
terraform import hcp_aws_network_peering.peer f709ec73-55d4-46d8-897d-816ebba28778:main-hvn:11eb60b3-d4ec-5eed-aacc-0242ac120015
# Using the provider-default project ID, the import ID is:
# {hvn_id}:{peering_id}
terraform import hcp_aws_network_peering.peer main-hvn:11eb60b3-d4ec-5eed-aacc-0242ac120015