Skip to content

Commit

Permalink
aws_vpc_route_table: retry read on new resource
Browse files Browse the repository at this point in the history
We are seeing failures when trying to read a newly created resource.
We should retry reads in those cases to allow for eventual consistency.
  • Loading branch information
patrickdillon committed Jul 12, 2022
1 parent f79cc52 commit d94464d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/service/ec2/vpc_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ func resourceRouteTableRead(d *schema.ResourceData, meta interface{}) error {
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig

routeTable, err := FindRouteTableByID(conn, d.Id())
outputRaw, err := tfresource.RetryWhenNewResourceNotFound(propagationTimeout, func() (interface{}, error) {
return FindRouteTableByID(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 @@ -229,6 +231,8 @@ func resourceRouteTableRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("error reading Route Table (%s): %w", d.Id(), err)
}

routeTable := outputRaw.(*ec2.RouteTable)

d.Set("vpc_id", routeTable.VpcId)

propagatingVGWs := make([]string, 0, len(routeTable.PropagatingVgws))
Expand Down

0 comments on commit d94464d

Please sign in to comment.