Skip to content

Commit 61b5176

Browse files
committed
provider/aws: Updating state when aws_sns_topic_subscription is (hashicorp#6629)
missing Fixes hashicorp#6625 When an SNS topic subscription was created with TF and then removed via the AWS Console, Terraform threw an error: ``` * aws_sns_topic_subscription.testme: NotFound: Subscription does not * exist status code: 404, request id: a22e7ed7-3630-5a8a-b767-317ac1440e24 ``` This PR will remove the topic subscription from state on a NotFound and will then readd the subscripton
1 parent 8229cdb commit 61b5176

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

builtin/providers/aws/resource_aws_sns_topic_subscription.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/aws/aws-sdk-go/aws"
14+
"github.com/aws/aws-sdk-go/aws/awserr"
1415
"github.com/aws/aws-sdk-go/service/sns"
1516
)
1617

@@ -155,6 +156,12 @@ func resourceAwsSnsTopicSubscriptionRead(d *schema.ResourceData, meta interface{
155156
SubscriptionArn: aws.String(d.Id()),
156157
})
157158
if err != nil {
159+
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NotFound" {
160+
log.Printf("[WARN] SNS Topic Subscription (%s) not found, error code (404)", d.Id())
161+
d.SetId("")
162+
return nil
163+
}
164+
158165
return err
159166
}
160167

0 commit comments

Comments
 (0)