Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCPE-1198: add CIDR guidance to HVN resource documentation #160

Merged
merged 5 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ description: |-

The HCP provider provides resources to manage [HashiCorp Cloud Platform](https://cloud.hashicorp.com/) (HCP) resources.

~> **Migration Required:** The release of HVN Routes in v0.7.0 includes breaking changes that affect `hcp_aws_network_peering` and `hcp_aws_transit_gateway_attachment`. [This guide](https://registry.terraform.io/providers/hashicorp/hcp/latest/docs/guides/hvn-route-migration-guide) walks through how to migrate to the new resource syntax.
Please pin to the previous version to avoid disruption until you are ready to migrate.

-> **Note:** Please refer to the provider's [Release Notes](https://github.com/hashicorp/terraform-provider-hcp/releases) for critical fixes.

## Authenticating with HCP
Expand Down
13 changes: 12 additions & 1 deletion docs/resources/hvn.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "hcp_hvn Resource - terraform-provider-hcp"
subcategory: ""
description: |-
Expand All @@ -10,6 +9,18 @@ description: |-

The HVN resource allows you to manage a HashiCorp Virtual Network in HCP.

We recommend the following when selecting the CIDR block of an HVN:

- The CIDR block value must be a private IPv4 CIDR block within the [RFC1918](https://datatracker.ietf.org/doc/html/rfc1918) address space (10.*.*.*, 192.168.*.*, 172.[16-31].*.*).

- The CIDR block value must be the first IP address of the desired CIDR block. The helper `cidrsubnet("172.16.1.1/24", 0, 0)` will specify the first address of the CIDR block in the first argument.

- The CIDR block value must end between /16 and /25.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other thing since we're adding some more guidance here (although definitely not blocking): I believe our APIs expect CIDR blocks to use the first IP address in the block, and will error if an arbitrary IP address within the block is used (and I think cidrsubnet() can help with this?). We could potentially add something to help guide users past that restriction.

Copy link
Contributor Author

@bcmdarroch bcmdarroch Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't know that.💡 I'll run this by control plane team:
The CIDR block value should be the first IP address of the desired CIDR block. The [cidrsubnet()](https://www.terraform.io/docs/language/functions/cidrsubnet.html) helper can be used to specify the first address.

Copy link
Contributor Author

@bcmdarroch bcmdarroch Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got 👍 from control plane. Went ahead and added a couple more rules that we're enforcing on the backend.


- If the CIDR block values for your HVN and VPCs overlap, then you will not be able to establish a connection. Ensure that any VPCs you plan to connect do not have overlapping values.

- The default HVN CIDR block value does not overlap with the default CIDR block value for AWS VPCs (172.31.0.0/16). However, if you are planning to use this HVN in production, we recommend adding a custom value instead of using the default.

## Example Usage

```terraform
Expand Down
3 changes: 0 additions & 3 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ description: |-

The HCP provider provides resources to manage [HashiCorp Cloud Platform](https://cloud.hashicorp.com/) (HCP) resources.

~> **Migration Required:** The release of HVN Routes in v0.7.0 includes breaking changes that affect `hcp_aws_network_peering` and `hcp_aws_transit_gateway_attachment`. [This guide](https://registry.terraform.io/providers/hashicorp/hcp/latest/docs/guides/hvn-route-migration-guide) walks through how to migrate to the new resource syntax.
Please pin to the previous version to avoid disruption until you are ready to migrate.

-> **Note:** Please refer to the provider's [Release Notes](https://github.com/hashicorp/terraform-provider-hcp/releases) for critical fixes.

## Authenticating with HCP
Expand Down
34 changes: 34 additions & 0 deletions templates/resources/hvn.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
page_title: "{{.Type}} {{.Name}} - {{.ProviderName}}"
subcategory: ""
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---

# {{.Type}} ({{.Name}})

{{ .Description | trimspace }}

We recommend the following when selecting the CIDR block of an HVN:

- The CIDR block value must be a private IPv4 CIDR block within the [RFC1918](https://datatracker.ietf.org/doc/html/rfc1918) address space (10.*.*.*, 192.168.*.*, 172.[16-31].*.*).

- The CIDR block value must be the first IP address of the desired CIDR block. The helper `cidrsubnet("172.16.1.1/24", 0, 0)` will specify the first address of the CIDR block in the first argument.

- The CIDR block value must end between /16 and /25.

- If the CIDR block values for your HVN and VPCs overlap, then you will not be able to establish a connection. Ensure that any VPCs you plan to connect do not have overlapping values.

- The default HVN CIDR block value does not overlap with the default CIDR block value for AWS VPCs (172.31.0.0/16). However, if you are planning to use this HVN in production, we recommend adding a custom value instead of using the default.

## Example Usage

{{ tffile "examples/resources/hcp_hvn/resource.tf" }}

{{ .SchemaMarkdown | trimspace }}

## Import

Import is supported using the following syntax:

{{ codefile "shell" "examples/resources/hcp_hvn/import.sh" }}