Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consistency check during CreateTopic to handle ABAC vs. eventual consistency issues #30432

Merged
merged 10 commits into from
Apr 14, 2023
3 changes: 3 additions & 0 deletions .changelog/30432.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_sns_topic: Fix IAM eventual consistency error creating SNS topics with ABAC-controlled permissions
```
7 changes: 6 additions & 1 deletion internal/service/sns/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,12 @@ func resourceTopicCreate(ctx context.Context, d *schema.ResourceData, meta inter

d.SetId(aws.StringValue(output.TopicArn))

err = putTopicAttributes(ctx, conn, d.Id(), attributes)
// Retry for eventual consistency; if ABAC is in use, this takes some time
// usually about 10s, presumably for tags really to be there, and we get a
// permissions error.
_, err = tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, func() (interface{}, error) {
return nil, putTopicAttributes(ctx, conn, d.Id(), attributes)
}, sns.ErrCodeAuthorizationErrorException, "no identity-based policy allows")

if err != nil {
return sdkdiag.AppendFromErr(diags, err)
Expand Down