From 2a09941f76f8e848697add118aff560d9e8b7c64 Mon Sep 17 00:00:00 2001 From: stack72 Date: Wed, 8 Jun 2016 16:00:13 +0200 Subject: [PATCH 1/2] provider/aws: Update state on `aws_elasticache_subnet_group` not found exception Fixes #7062 make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSElasticacheSubnetGroup' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /vendor/) TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSElasticacheSubnetGroup -timeout 120m === RUN TestAccAWSElasticacheSubnetGroup_basic --- PASS: TestAccAWSElasticacheSubnetGroup_basic (44.62s) === RUN TestAccAWSElasticacheSubnetGroup_update --- PASS: TestAccAWSElasticacheSubnetGroup_update (73.74s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 118.379s --- .../providers/aws/resource_aws_elasticache_subnet_group.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/providers/aws/resource_aws_elasticache_subnet_group.go b/builtin/providers/aws/resource_aws_elasticache_subnet_group.go index 7f78cd362..516528693 100644 --- a/builtin/providers/aws/resource_aws_elasticache_subnet_group.go +++ b/builtin/providers/aws/resource_aws_elasticache_subnet_group.go @@ -87,6 +87,11 @@ 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. + d.SetId("") + return nil + } return err } if len(res.CacheSubnetGroups) == 0 { From 1624c7e27f542e1aacf597720943cb43703ac2ec Mon Sep 17 00:00:00 2001 From: clint shryock Date: Wed, 8 Jun 2016 13:35:49 -0500 Subject: [PATCH 2/2] provider/aws: Log ElasticCache subnet removal --- builtin/providers/aws/resource_aws_elasticache_subnet_group.go | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/providers/aws/resource_aws_elasticache_subnet_group.go b/builtin/providers/aws/resource_aws_elasticache_subnet_group.go index 516528693..af684af42 100644 --- a/builtin/providers/aws/resource_aws_elasticache_subnet_group.go +++ b/builtin/providers/aws/resource_aws_elasticache_subnet_group.go @@ -89,6 +89,7 @@ func resourceAwsElasticacheSubnetGroupRead(d *schema.ResourceData, meta interfac 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 }