From 9cee18b3de8ea63c5403cc6176f501ea4aaf33bb Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 5 Nov 2015 14:31:55 +0000 Subject: [PATCH] ElastiCache cluster read tolerates removed cluster. Previously it would fail if a Terraform-managed ElastiCache cluster were deleted outside of Terraform. Now it marks it as deleted in the state so that Terraform can know it doesn't need to be destroyed, and can potentially recreate it if asked. --- builtin/providers/aws/resource_aws_elasticache_cluster.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builtin/providers/aws/resource_aws_elasticache_cluster.go b/builtin/providers/aws/resource_aws_elasticache_cluster.go index 3460fb292ff8..f2410dcd509a 100644 --- a/builtin/providers/aws/resource_aws_elasticache_cluster.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster.go @@ -241,6 +241,12 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{}) res, err := conn.DescribeCacheClusters(req) if err != nil { + if eccErr, ok := err.(awserr.Error); ok && eccErr.Code() == "CacheClusterNotFound" { + log.Printf("[WARN] ElastiCache Cluster (%s) not found", d.Id()) + d.SetId("") + return nil + } + return err }