Skip to content

Commit

Permalink
Merge pull request #30994 from alenkacz/av/fix-read-retry
Browse files Browse the repository at this point in the history
Fix inconsistent read after create for vpc_endpoint_route_table_association
  • Loading branch information
ewbankkit authored Apr 26, 2023
2 parents 8c35be9 + 3f1945f commit 5bde439
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/30994.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_vpc_endpoint_route_table_association: Retry resource Create for EC2 eventual consistency
```
5 changes: 3 additions & 2 deletions internal/service/ec2/vpc_endpoint_route_table_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func resourceVPCEndpointRouteTableAssociationCreate(ctx context.Context, d *sche

log.Printf("[DEBUG] Creating VPC Endpoint Route Table Association: %s", input)
_, err := conn.ModifyVpcEndpointWithContext(ctx, input)

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating VPC Endpoint Route Table Association (%s): %s", id, err)
}
Expand All @@ -82,7 +81,9 @@ func resourceVPCEndpointRouteTableAssociationRead(ctx context.Context, d *schema
// Human friendly ID for error messages since d.Id() is non-descriptive
id := fmt.Sprintf("%s/%s", endpointID, routeTableID)

err := FindVPCEndpointRouteTableAssociationExists(ctx, conn, endpointID, routeTableID)
_, err := tfresource.RetryWhenNewResourceNotFound(ctx, RouteTableAssociationPropagationTimeout, func() (interface{}, error) {
return nil, FindVPCEndpointRouteTableAssociationExists(ctx, conn, endpointID, routeTableID)
}, d.IsNewResource())

if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] VPC Endpoint Route Table Association (%s) not found, removing from state", id)
Expand Down

0 comments on commit 5bde439

Please sign in to comment.