diff --git a/builtin/providers/aws/resource_aws_api_gateway_resource.go b/builtin/providers/aws/resource_aws_api_gateway_resource.go index 6fa9f26fc..a0f138c13 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_resource.go +++ b/builtin/providers/aws/resource_aws_api_gateway_resource.go @@ -75,6 +75,10 @@ func resourceAwsApiGatewayResourceRead(d *schema.ResourceData, meta interface{}) }) if err != nil { + if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NotFoundException" { + d.SetId("") + return nil + } return err } diff --git a/builtin/providers/aws/resource_aws_api_gateway_rest_api.go b/builtin/providers/aws/resource_aws_api_gateway_rest_api.go index 9254c285c..65d3afdc5 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_rest_api.go +++ b/builtin/providers/aws/resource_aws_api_gateway_rest_api.go @@ -87,6 +87,10 @@ func resourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{}) RestApiId: aws.String(d.Id()), }) if err != nil { + if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NotFoundException" { + d.SetId("") + return nil + } return err }