Skip to content

Commit

Permalink
Merge pull request #9813 from terraform-providers/rfd-retry-sqs
Browse files Browse the repository at this point in the history
Final retries for SQS resources
  • Loading branch information
ryndaniels authored Aug 21, 2019
2 parents d941469 + 27d186e commit f90dfa8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions aws/resource_aws_sqs_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ func resourceAwsSqsQueueCreate(d *schema.ResourceData, meta interface{}) error {
}
return nil
})
if isResourceTimeoutError(err) {
output, err = sqsconn.CreateQueue(req)
}
if err != nil {
return fmt.Errorf("Error creating SQS queue: %s", err)
}
Expand Down
21 changes: 19 additions & 2 deletions aws/resource_aws_sqs_queue_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ func resourceAwsSqsQueuePolicyUpsert(d *schema.ResourceData, meta interface{}) e
AttributeNames: []*string{aws.String(sqs.QueueAttributeNamePolicy)},
}
notUpdatedError := fmt.Errorf("SQS attribute %s not updated", sqs.QueueAttributeNamePolicy)
var out *sqs.GetQueueAttributesOutput
err = resource.Retry(1*time.Minute, func() *resource.RetryError {
log.Printf("[DEBUG] Reading SQS attributes: %s", gqaInput)
out, err := conn.GetQueueAttributes(gqaInput)
var err error
out, err = conn.GetQueueAttributes(gqaInput)
if err != nil {
return resource.NonRetryableError(err)
}
Expand All @@ -88,8 +90,23 @@ func resourceAwsSqsQueuePolicyUpsert(d *schema.ResourceData, meta interface{}) e
}
return nil
})
if isResourceTimeoutError(err) {
out, err = conn.GetQueueAttributes(gqaInput)
if err == nil {
queuePolicy, ok := out.Attributes[sqs.QueueAttributeNamePolicy]
if !ok {
return notUpdatedError
}

var equivalent bool
equivalent, err = awspolicy.PoliciesAreEquivalent(*queuePolicy, policy)
if !equivalent {
return notUpdatedError
}
}
}
if err != nil {
return err
return fmt.Errorf("Error updating SQS queue attributes: %s", err)
}

d.SetId(url)
Expand Down

0 comments on commit f90dfa8

Please sign in to comment.