provider/aws: refresh state on SQS Queue not found (#6381)
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
This commit is contained in:
parent
0a8ea049ef
commit
ee3d89a4cd
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/sqs"
|
"github.com/aws/aws-sdk-go/service/sqs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -177,6 +178,14 @@ func resourceAwsSqsQueueRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue