Skip to content

Commit

Permalink
Merge pull request #35861 from appian/b-sqs-queue-policy-retry
Browse files Browse the repository at this point in the history
Add eventual consistency protection on queue policy attributes
  • Loading branch information
ewbankkit authored Feb 16, 2024
2 parents bcaa2f8 + 05334b2 commit dafadc1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/35861.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_sqs_queue_policy: Retry IAM eventual consistency errors
```
4 changes: 3 additions & 1 deletion internal/service/sqs/attribute_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func (h *queueAttributeHandler) Upsert(ctx context.Context, d *schema.ResourceDa
QueueUrl: aws.String(url),
}

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

if err != nil {
return diag.Errorf("setting SQS Queue (%s) attribute (%s): %s", url, h.AttributeName, err)
Expand Down
11 changes: 9 additions & 2 deletions internal/service/sqs/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

package sqs

import "time"

const (
propagationTimeout = 1 * time.Minute
)

const (
fifoQueueNameSuffix = ".fifo"
)
Expand Down Expand Up @@ -41,6 +47,7 @@ func fifoThroughputLimit_Values() []string {
}

const (
errCodeQueueDoesNotExist = "AWS.SimpleQueueService.NonExistentQueue"
errCodeQueueDeletedRecently = "AWS.SimpleQueueService.QueueDeletedRecently"
errCodeQueueDoesNotExist = "AWS.SimpleQueueService.NonExistentQueue"
errCodeQueueDeletedRecently = "AWS.SimpleQueueService.QueueDeletedRecently"
errCodeInvalidAttributeValue = "InvalidAttributeValue"
)

0 comments on commit dafadc1

Please sign in to comment.