diff --git a/builtin/providers/aws/resource_aws_elasticache_subnet_group.go b/builtin/providers/aws/resource_aws_elasticache_subnet_group.go index 7f78cd3626..af684af42a 100644 --- a/builtin/providers/aws/resource_aws_elasticache_subnet_group.go +++ b/builtin/providers/aws/resource_aws_elasticache_subnet_group.go @@ -87,6 +87,12 @@ func resourceAwsElasticacheSubnetGroupRead(d *schema.ResourceData, meta interfac res, err := conn.DescribeCacheSubnetGroups(req) if err != nil { + if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() == "CacheSubnetGroupNotFoundFault" { + // Update state to indicate the db subnet no longer exists. + log.Printf("[WARN] Elasticache Subnet Group (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } return err } if len(res.CacheSubnetGroups) == 0 {