Skip to content

Commit

Permalink
provider/aws: refresh state on SQS Queue not found (hashicorp#6381)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stack72 authored and Xavier Sellier committed May 17, 2016
1 parent 482463c commit 33def36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions builtin/providers/aws/resource_aws_sqs_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 33def36

Please sign in to comment.