Skip to content

Commit

Permalink
Fix inconsistent read after create for vpc_route_table
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz committed Jun 12, 2023
1 parent c39a208 commit 47a252c
Showing 1 changed file with 4 additions and 2 deletions.
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 47a252c

Please sign in to comment.