Skip to content

Commit b663d36

Browse files
committed
Update for VPCs also
1 parent a9e3b62 commit b663d36

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

website/docs/r/ec2_transit_gateway_route_table_association.html.markdown

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,43 @@ resource "aws_ec2_transit_gateway_route_table_association" "example" {
5555

5656
~> **NOTE:** Avoid using the `aws_ec2_transit_gateway_dx_gateway_attachment` data source to retrieve the attachment ID, as this can cause unnecessary resource recreation when unrelated attributes of the Direct Connect Gateway association change (such as `allowed_prefixes`). Always reference the `transit_gateway_attachment_id` attribute directly from the `aws_dx_gateway_association` resource when available.
5757

58+
### VPC Attachment Association
59+
60+
For VPC attachments, always reference the attachment resource's `id` attribute directly. Avoid using data sources or lifecycle rules that might cause the attachment ID to become unknown during planning:
61+
62+
```terraform
63+
resource "aws_vpc" "example" {
64+
cidr_block = "10.0.0.0/16"
65+
}
66+
67+
resource "aws_subnet" "example" {
68+
vpc_id = aws_vpc.example.id
69+
cidr_block = "10.0.1.0/24"
70+
}
71+
72+
resource "aws_ec2_transit_gateway" "example" {
73+
description = "example"
74+
}
75+
76+
resource "aws_ec2_transit_gateway_vpc_attachment" "example" {
77+
subnet_ids = [aws_subnet.example.id]
78+
transit_gateway_id = aws_ec2_transit_gateway.example.id
79+
vpc_id = aws_vpc.example.id
80+
}
81+
82+
resource "aws_ec2_transit_gateway_route_table" "example" {
83+
transit_gateway_id = aws_ec2_transit_gateway.example.id
84+
}
85+
86+
# Correct: Reference the VPC attachment ID directly
87+
resource "aws_ec2_transit_gateway_route_table_association" "example" {
88+
transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.example.id
89+
transit_gateway_route_table_id = aws_ec2_transit_gateway_route_table.example.id
90+
}
91+
```
92+
93+
~> **NOTE:** When the `transit_gateway_attachment_id` changes (for example, when a VPC attachment is replaced), this resource will be recreated. This is the correct behavior to maintain consistency between the attachment and its route table association.
94+
5895
## Argument Reference
5996

6097
This resource supports the following arguments:

website/docs/r/ec2_transit_gateway_route_table_propagation.html.markdown

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,43 @@ resource "aws_ec2_transit_gateway_route_table_propagation" "example" {
5555

5656
~> **NOTE:** Avoid using the `aws_ec2_transit_gateway_dx_gateway_attachment` data source to retrieve the attachment ID, as this can cause unnecessary resource recreation when unrelated attributes of the Direct Connect Gateway association change (such as `allowed_prefixes`). Always reference the `transit_gateway_attachment_id` attribute directly from the `aws_dx_gateway_association` resource when available.
5757

58+
### VPC Attachment Propagation
59+
60+
For VPC attachments, always reference the attachment resource's `id` attribute directly. Avoid using data sources or lifecycle rules that might cause the attachment ID to become unknown during planning:
61+
62+
```terraform
63+
resource "aws_vpc" "example" {
64+
cidr_block = "10.0.0.0/16"
65+
}
66+
67+
resource "aws_subnet" "example" {
68+
vpc_id = aws_vpc.example.id
69+
cidr_block = "10.0.1.0/24"
70+
}
71+
72+
resource "aws_ec2_transit_gateway" "example" {
73+
description = "example"
74+
}
75+
76+
resource "aws_ec2_transit_gateway_vpc_attachment" "example" {
77+
subnet_ids = [aws_subnet.example.id]
78+
transit_gateway_id = aws_ec2_transit_gateway.example.id
79+
vpc_id = aws_vpc.example.id
80+
}
81+
82+
resource "aws_ec2_transit_gateway_route_table" "example" {
83+
transit_gateway_id = aws_ec2_transit_gateway.example.id
84+
}
85+
86+
# Correct: Reference the VPC attachment ID directly
87+
resource "aws_ec2_transit_gateway_route_table_propagation" "example" {
88+
transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.example.id
89+
transit_gateway_route_table_id = aws_ec2_transit_gateway_route_table.example.id
90+
}
91+
```
92+
93+
~> **NOTE:** When the `transit_gateway_attachment_id` changes (for example, when a VPC attachment is replaced), this resource will be recreated. This is the correct behavior to maintain consistency between the attachment and its route table propagation.
94+
5895
## Argument Reference
5996

6097
This resource supports the following arguments:

0 commit comments

Comments
 (0)