From c627e17d511e29dfefc26856d8d2c0b32495b9c2 Mon Sep 17 00:00:00 2001 From: stack72 Date: Wed, 27 Apr 2016 18:51:13 +0100 Subject: [PATCH] provider/aws: refresh state on SQS Queue not found When an SQS queue was deleted from the AWS Console, an error was thrown to say that the Queue could not be found. This is now fixed to remove the queue from the state on a specific not found exception --- builtin/providers/aws/resource_aws_sqs_queue.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/builtin/providers/aws/resource_aws_sqs_queue.go b/builtin/providers/aws/resource_aws_sqs_queue.go index fb3833072997..7d7733bf323a 100644 --- a/builtin/providers/aws/resource_aws_sqs_queue.go +++ b/builtin/providers/aws/resource_aws_sqs_queue.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/sqs" ) @@ -177,6 +178,14 @@ func resourceAwsSqsQueueRead(d *schema.ResourceData, meta interface{}) error { }) if err != nil { + if awsErr, ok := err.(awserr.Error); ok { + log.Printf("ERROR Found %s", awsErr.Code()) + if "AWS.SimpleQueueService.NonExistentQueue" == awsErr.Code() { + d.SetId("") + log.Printf("[DEBUG] SQS Queue (%s) not found", d.Get("name").(string)) + return nil + } + } return err }