diff --git a/.changelog/1253.txt b/.changelog/1253.txt new file mode 100644 index 000000000..2e4e6a057 --- /dev/null +++ b/.changelog/1253.txt @@ -0,0 +1,3 @@ +```release-note:improvement +Added resources that are required for full functionality to the example code for `hcp_aws_transit_gateway_attachment`: , `aws_subnet`, `aws_ec2_transit_gateway_vpc_attachment, and `aws_ `aws_route` pointing back to the HVN attachment. +``` diff --git a/contributing/README.md b/contributing/README.md index 9469b7afb..70b4530de 100644 --- a/contributing/README.md +++ b/contributing/README.md @@ -55,7 +55,9 @@ Then commit the changes to `go.mod` and `go.sum`. ## Generating Docs -To generate or update documentation, run `go generate`. +Documentation is generated from `*.md.tmpl` files in the `templates/` directory, and code samples are sourced from the `examples/` directory. + +To generate or update documentation after modifying the files in the above locations, run `go generate`. ```shell script $ go generate ``` diff --git a/docs/resources/aws_transit_gateway_attachment.md b/docs/resources/aws_transit_gateway_attachment.md index 940461bf2..98e2f936a 100644 --- a/docs/resources/aws_transit_gateway_attachment.md +++ b/docs/resources/aws_transit_gateway_attachment.md @@ -27,6 +27,14 @@ resource "hcp_hvn" "main" { resource "aws_vpc" "example" { cidr_block = "172.31.0.0/16" + tags = { + Name = "example-vpc" + } +} + +resource "aws_subnet" "example" { + vpc_id = aws_vpc.example.id + cidr_block = "172.31.1.0/24" } resource "aws_ec2_transit_gateway" "example" { @@ -35,6 +43,12 @@ resource "aws_ec2_transit_gateway" "example" { } } +resource "aws_ec2_transit_gateway_vpc_attachment" "example" { + subnet_ids = [aws_subnet.example.id] + transit_gateway_id = aws_ec2_transit_gateway.example.id + vpc_id = aws_vpc.example.id +} + resource "aws_ram_resource_share" "example" { name = "example-resource-share" allow_external_principals = true @@ -72,6 +86,15 @@ resource "hcp_hvn_route" "route" { resource "aws_ec2_transit_gateway_vpc_attachment_accepter" "example" { transit_gateway_attachment_id = hcp_aws_transit_gateway_attachment.example.provider_transit_gateway_attachment_id } + +resource "aws_route" "example" { + route_table_id = aws_vpc.example.main_route_table_id + destination_cidr_block = hcp_hvn.main.cidr_block + transit_gateway_id = aws_ec2_transit_gateway.example.id + depends_on = [ + aws_ec2_transit_gateway_vpc_attachment.example + ] +} ``` diff --git a/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf b/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf index 64e152846..8befb2a40 100644 --- a/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf +++ b/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf @@ -11,6 +11,14 @@ resource "hcp_hvn" "main" { resource "aws_vpc" "example" { cidr_block = "172.31.0.0/16" + tags = { + Name = "example-vpc" + } +} + +resource "aws_subnet" "example" { + vpc_id = aws_vpc.example.id + cidr_block = "172.31.1.0/24" } resource "aws_ec2_transit_gateway" "example" { @@ -19,6 +27,12 @@ resource "aws_ec2_transit_gateway" "example" { } } +resource "aws_ec2_transit_gateway_vpc_attachment" "example" { + subnet_ids = [aws_subnet.example.id] + transit_gateway_id = aws_ec2_transit_gateway.example.id + vpc_id = aws_vpc.example.id +} + resource "aws_ram_resource_share" "example" { name = "example-resource-share" allow_external_principals = true @@ -56,3 +70,12 @@ resource "hcp_hvn_route" "route" { resource "aws_ec2_transit_gateway_vpc_attachment_accepter" "example" { transit_gateway_attachment_id = hcp_aws_transit_gateway_attachment.example.provider_transit_gateway_attachment_id } + +resource "aws_route" "example" { + route_table_id = aws_vpc.example.main_route_table_id + destination_cidr_block = hcp_hvn.main.cidr_block + transit_gateway_id = aws_ec2_transit_gateway.example.id + depends_on = [ + aws_ec2_transit_gateway_vpc_attachment.example + ] +}