From a9734740a68c9be6e97942732e83324591b95581 Mon Sep 17 00:00:00 2001 From: moonorange Date: Sat, 9 Mar 2024 18:10:49 +0530 Subject: [PATCH 1/3] fix: retry ReplaceTopicRuleWithContext when error message contains sts:AssumeRole --- internal/service/iot/topic_rule.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/service/iot/topic_rule.go b/internal/service/iot/topic_rule.go index af0f6de0a7a..2949d4aacdd 100644 --- a/internal/service/iot/topic_rule.go +++ b/internal/service/iot/topic_rule.go @@ -1372,7 +1372,11 @@ func resourceTopicRuleUpdate(ctx context.Context, d *schema.ResourceData, meta i TopicRulePayload: expandTopicRulePayload(d), } - _, err := conn.ReplaceTopicRuleWithContext(ctx, input) + _, err := tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, + func() (interface{}, error) { + return conn.ReplaceTopicRuleWithContext(ctx, input) + }, + iot.ErrCodeInvalidRequestException, "sts:AssumeRole") if err != nil { return sdkdiag.AppendErrorf(diags, "replacing IoT Topic Rule (%s): %s", d.Id(), err) From 762af66def0f21c8c8a8f8a8983ecb923a348d50 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 3 Jul 2024 09:07:02 -0400 Subject: [PATCH 2/3] Add CHANGELOG entry. --- .changelog/36286.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/36286.txt diff --git a/.changelog/36286.txt b/.changelog/36286.txt new file mode 100644 index 00000000000..108fa87be0a --- /dev/null +++ b/.changelog/36286.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_iot_topic_rule: Retry IAM eventual consistency errors on Update +``` \ No newline at end of file From 43d5c83bb5017b73201f9df7d64c6a8e445295f7 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 3 Jul 2024 09:07:44 -0400 Subject: [PATCH 3/3] r/aws_iot_topic_rule: Make update retry similar to create. --- internal/service/iot/topic_rule.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/service/iot/topic_rule.go b/internal/service/iot/topic_rule.go index 268dbbd121f..e6a63c93d75 100644 --- a/internal/service/iot/topic_rule.go +++ b/internal/service/iot/topic_rule.go @@ -1379,9 +1379,10 @@ func resourceTopicRuleUpdate(ctx context.Context, d *schema.ResourceData, meta i TopicRulePayload: expandTopicRulePayload(d), } - _, err := tfresource.RetryWhenIsAErrorMessageContains[*awstypes.InvalidRequestException](ctx, propagationTimeout, func() (interface{}, error) { - return conn.ReplaceTopicRule(ctx, input) - }, "unable to assume role") + _, err := tfresource.RetryWhenIsA[*awstypes.InvalidRequestException](ctx, propagationTimeout, + func() (interface{}, error) { + return conn.ReplaceTopicRule(ctx, input) + }) if err != nil { return sdkdiag.AppendErrorf(diags, "replacing IoT Topic Rule (%s): %s", d.Id(), err)