Skip to content

Commit 23b9893

Browse files
committed
Add eventual consistency protection on queue policy attributes
1 parent 6db9841 commit 23b9893

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

internal/service/sqs/attribute_funcs.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ package sqs
55

66
import (
77
"context"
8-
"log"
9-
108
"github.com/aws/aws-sdk-go-v2/aws"
119
"github.com/aws/aws-sdk-go-v2/service/sqs"
1210
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
@@ -18,6 +16,7 @@ import (
1816
"github.com/hashicorp/terraform-provider-aws/internal/flex"
1917
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
2018
"github.com/hashicorp/terraform-provider-aws/internal/verify"
19+
"log"
2120
)
2221

2322
type queueAttributeHandler struct {
@@ -43,7 +42,9 @@ func (h *queueAttributeHandler) Upsert(ctx context.Context, d *schema.ResourceDa
4342
QueueUrl: aws.String(url),
4443
}
4544

46-
_, err = conn.SetQueueAttributes(ctx, input)
45+
_, err = tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, func() (interface{}, error) {
46+
return conn.SetQueueAttributes(ctx, input)
47+
}, errCodeInvalidAttributeValue, "Invalid value for the parameter Policy")
4748

4849
if err != nil {
4950
return diag.Errorf("setting SQS Queue (%s) attribute (%s): %s", url, h.AttributeName, err)

internal/service/sqs/consts.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
package sqs
55

6+
import "time"
7+
8+
const (
9+
propagationTimeout = 1 * time.Minute
10+
)
11+
612
const (
713
fifoQueueNameSuffix = ".fifo"
814
)
@@ -41,6 +47,7 @@ func fifoThroughputLimit_Values() []string {
4147
}
4248

4349
const (
44-
errCodeQueueDoesNotExist = "AWS.SimpleQueueService.NonExistentQueue"
45-
errCodeQueueDeletedRecently = "AWS.SimpleQueueService.QueueDeletedRecently"
50+
errCodeQueueDoesNotExist = "AWS.SimpleQueueService.NonExistentQueue"
51+
errCodeQueueDeletedRecently = "AWS.SimpleQueueService.QueueDeletedRecently"
52+
errCodeInvalidAttributeValue = "InvalidAttributeValue"
4653
)

0 commit comments

Comments
 (0)