Skip to content

Commit 1cac773

Browse files
committed
Switch codebuild to backoff
1 parent a70a78a commit 1cac773

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

internal/service/cloudfront/create_invalidation_action.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ func (a *createInvalidationAction) Invoke(ctx context.Context, req action.Invoke
218218
})
219219

220220
// Wait for invalidation to complete with periodic progress updates using actionwait
221+
// Use fixed interval since CloudFront invalidations have predictable timing and
222+
// don't benefit from exponential backoff - status changes are infrequent and consistent
221223
_, err = actionwait.WaitForStatus(ctx, func(ctx context.Context) (actionwait.FetchResult[struct{}], error) {
222224
input := cloudfront.GetInvalidationInput{
223225
DistributionId: aws.String(distributionID),

internal/service/codebuild/start_build_action.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/hashicorp/terraform-plugin-framework/types"
1818
"github.com/hashicorp/terraform-plugin-log/tflog"
1919
"github.com/hashicorp/terraform-provider-aws/internal/actionwait"
20+
"github.com/hashicorp/terraform-provider-aws/internal/backoff"
2021
"github.com/hashicorp/terraform-provider-aws/internal/framework"
2122
fwflex "github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
2223
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
@@ -134,7 +135,9 @@ func (a *startBuildAction) Invoke(ctx context.Context, req action.InvokeRequest,
134135
Message: "Build started, waiting for completion...",
135136
})
136137

137-
// Poll for build completion using actionwait
138+
// Poll for build completion using actionwait with backoff strategy
139+
// Use backoff since builds can take a long time and status changes less frequently
140+
// as the build progresses - start with frequent polling then back off
138141
_, err = actionwait.WaitForStatus(ctx, func(ctx context.Context) (actionwait.FetchResult[*awstypes.Build], error) {
139142
input := codebuild.BatchGetBuildsInput{Ids: []string{buildID}}
140143
batch, berr := conn.BatchGetBuilds(ctx, &input)
@@ -148,7 +151,7 @@ func (a *startBuildAction) Invoke(ctx context.Context, req action.InvokeRequest,
148151
return actionwait.FetchResult[*awstypes.Build]{Status: actionwait.Status(b.BuildStatus), Value: &b}, nil
149152
}, actionwait.Options[*awstypes.Build]{
150153
Timeout: timeout,
151-
Interval: actionwait.FixedInterval(actionwait.DefaultPollInterval),
154+
Interval: actionwait.WithBackoffDelay(backoff.DefaultSDKv2HelperRetryCompatibleDelay()),
152155
ProgressInterval: 2 * time.Minute,
153156
SuccessStates: []actionwait.Status{actionwait.Status(awstypes.StatusTypeSucceeded)},
154157
TransitionalStates: []actionwait.Status{

internal/service/ec2/ec2_stop_instance_action.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ func (a *stopInstanceAction) Invoke(ctx context.Context, req action.InvokeReques
185185
}
186186

187187
// Wait for instance to stop with periodic progress updates using actionwait
188+
// Use fixed interval since EC2 instance state transitions are predictable and
189+
// relatively quick - consistent polling every 10s is optimal for this operation
188190
_, err = actionwait.WaitForStatus(ctx, func(ctx context.Context) (actionwait.FetchResult[struct{}], error) {
189191
instance, derr := findInstanceByID(ctx, conn, instanceID)
190192
if derr != nil {

0 commit comments

Comments
 (0)