From 91cb65dd05cb739b43510ec6a9e2b696fc3ccba1 Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 28 Jan 2016 22:50:39 +0000 Subject: [PATCH] Provider/aws - SNS Topics deleted from the UI were causing Terraform to throw an error: * aws_sns_topic_subscription.checker: NotFound: Subscription does not * exist status code: 404, request id: b8ca0c27-1a62-57b3-8b96-43038a0ead86 Terraform wasn't refreshing the state when the topic gave a 404 --- builtin/providers/aws/resource_aws_sns_topic.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builtin/providers/aws/resource_aws_sns_topic.go b/builtin/providers/aws/resource_aws_sns_topic.go index a64f4b5d2c0c..300de37940c5 100644 --- a/builtin/providers/aws/resource_aws_sns_topic.go +++ b/builtin/providers/aws/resource_aws_sns_topic.go @@ -163,6 +163,12 @@ func resourceAwsSnsTopicRead(d *schema.ResourceData, meta interface{}) error { }) if err != nil { + if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NotFound" { + log.Printf("[WARN] SNS Topic (%s) not found, error code (404)", d.Id()) + d.SetId("") + return nil + } + return err }