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

Fix inconsistent read after create for vpc_route_table #30999

Merged
merged 3 commits into from
Jun 16, 2023
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: 3 additions & 0 deletions .changelog/30999.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_route_table: Fix `reading Route Table (rtb-abcd1234): couldn't find resource` errors when reading new resource
```
6 changes: 4 additions & 2 deletions internal/service/ec2/vpc_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ func resourceRouteTableCreate(ctx context.Context, d *schema.ResourceData, meta
func resourceRouteTableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).EC2Conn(ctx)

routeTable, err := FindRouteTableByID(ctx, conn, d.Id())
outputRaw, err := tfresource.RetryWhenNewResourceNotFound(ctx, RouteTableAssociationPropagationTimeout, func() (interface{}, error) {
return FindRouteTableByID(ctx, conn, d.Id())
}, d.IsNewResource())

if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] Route Table (%s) not found, removing from state", d.Id())
Expand All @@ -219,6 +220,7 @@ func resourceRouteTableRead(ctx context.Context, d *schema.ResourceData, meta in
return sdkdiag.AppendErrorf(diags, "reading Route Table (%s): %s", d.Id(), err)
}

routeTable := outputRaw.(*ec2.RouteTable)
ownerID := aws.StringValue(routeTable.OwnerId)
arn := arn.ARN{
Partition: meta.(*conns.AWSClient).Partition,
Expand Down