Skip to content

Commit

Permalink
Merge pull request #30999 from alenkacz/av/fix-read-retry-routetable
Browse files Browse the repository at this point in the history
Fix inconsistent read after create for vpc_route_table
  • Loading branch information
ewbankkit authored Jun 16, 2023
2 parents d06fa85 + 0ca5545 commit 1f8c772
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit 1f8c772

Please sign in to comment.