Skip to content

Commit 9300c25

Browse files
authored
Merge pull request #44489 from kamilturek/b-aws_cloudwatch_event_rule-limit-exceeded-exception-infinite-retries
r/aws_cloudwatch_event_rule: Do not retry on `LimitExceededException`
2 parents 3f1aeb8 + b0f3bed commit 9300c25

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.changelog/44489.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/aws_cloudwatch_event_rule: Do not retry on `LimitExceededException`
3+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package events
5+
6+
import (
7+
"context"
8+
9+
"github.com/aws/aws-sdk-go-v2/aws"
10+
"github.com/aws/aws-sdk-go-v2/aws/retry"
11+
"github.com/aws/aws-sdk-go-v2/service/eventbridge"
12+
awstypes "github.com/aws/aws-sdk-go-v2/service/eventbridge/types"
13+
"github.com/hashicorp/terraform-plugin-log/tflog"
14+
"github.com/hashicorp/terraform-provider-aws/internal/conns"
15+
"github.com/hashicorp/terraform-provider-aws/internal/errs"
16+
"github.com/hashicorp/terraform-provider-aws/internal/vcr"
17+
)
18+
19+
func (p *servicePackage) withExtraOptions(ctx context.Context, config map[string]any) []func(*eventbridge.Options) {
20+
cfg := *(config["aws_sdkv2_config"].(*aws.Config))
21+
22+
return []func(*eventbridge.Options){
23+
func(o *eventbridge.Options) {
24+
retryables := []retry.IsErrorRetryable{
25+
retry.IsErrorRetryableFunc(func(err error) aws.Ternary {
26+
if errs.IsAErrorMessageContains[*awstypes.LimitExceededException](err, "The requested resource exceeds the maximum number allowed") {
27+
return aws.FalseTernary
28+
}
29+
return aws.UnknownTernary // Delegate to configured Retryer.
30+
}),
31+
}
32+
// Include go-vcr retryable to prevent generated client retryer from being overridden
33+
if inContext, ok := conns.FromContext(ctx); ok && inContext.VCREnabled() {
34+
tflog.Info(ctx, "overriding retry behavior to immediately return VCR errors")
35+
retryables = append(retryables, vcr.InteractionNotFoundRetryableFunc)
36+
}
37+
38+
o.Retryer = conns.AddIsErrorRetryables(cfg.Retryer().(aws.RetryerV2), retryables...)
39+
},
40+
}
41+
}

0 commit comments

Comments
 (0)