Skip to content

Commit 9cee18b

Browse files
stack72apparentlymart
authored andcommitted
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.
1 parent bf11be8 commit 9cee18b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

builtin/providers/aws/resource_aws_elasticache_cluster.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{})
241241

242242
res, err := conn.DescribeCacheClusters(req)
243243
if err != nil {
244+
if eccErr, ok := err.(awserr.Error); ok && eccErr.Code() == "CacheClusterNotFound" {
245+
log.Printf("[WARN] ElastiCache Cluster (%s) not found", d.Id())
246+
d.SetId("")
247+
return nil
248+
}
249+
244250
return err
245251
}
246252

0 commit comments

Comments
 (0)