From de6161fe18b82ed3bdea907560b8f1337c11a278 Mon Sep 17 00:00:00 2001 From: stack72 Date: Wed, 24 Aug 2016 12:42:06 +0100 Subject: [PATCH] provider/aws: Refresh `aws_route` from state if `aws_route_table` not found Fixes #5288 Fixes #8388 ``` TESTS TBC ``` --- builtin/providers/aws/resource_aws_route.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/providers/aws/resource_aws_route.go b/builtin/providers/aws/resource_aws_route.go index 9f090fad6106..0bcc545fd2b0 100644 --- a/builtin/providers/aws/resource_aws_route.go +++ b/builtin/providers/aws/resource_aws_route.go @@ -197,6 +197,11 @@ func resourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn route, err := findResourceRoute(conn, d.Get("route_table_id").(string), d.Get("destination_cidr_block").(string)) if err != nil { + if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() == "InvalidRouteTableID.NotFound" { + log.Printf("[WARN] AWS RouteTable not found. Removing Route from state") + d.SetId("") + return nil + } return err } resourceAwsRouteSetResourceData(d, route)