-
Notifications
You must be signed in to change notification settings - Fork 9.8k
actionwait: add polling library for actions #44465
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
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
|
Most recent: % make t T=TestAccEC2StopInstanceAction_basic K=ec2
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 f-polling-library-for-actions 🌿...
TF_ACC=1 go1.24.6 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2StopInstanceAction_basic' -timeout 360m -vet=off
2025/09/30 17:45:05 Creating Terraform AWS Provider (SDKv2-style)...
2025/09/30 17:45:05 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccEC2StopInstanceAction_basic
=== PAUSE TestAccEC2StopInstanceAction_basic
=== CONT TestAccEC2StopInstanceAction_basic
ec2_stop_instance_action_test.go:328: Progress: Starting stop operation for EC2 instance i-04068524d01beb19b...
ec2_stop_instance_action_test.go:328: Progress: Sending stop command to EC2 instance i-04068524d01beb19b...
ec2_stop_instance_action_test.go:328: Progress: Stop command sent to EC2 instance i-04068524d01beb19b, waiting for instance to stop...
ec2_stop_instance_action_test.go:328: Progress: EC2 instance i-04068524d01beb19b is currently in state 'running', continuing to wait for 'stopped'...
ec2_stop_instance_action_test.go:328: Progress: EC2 instance i-04068524d01beb19b is currently in state 'stopping', continuing to wait for 'stopped'...
ec2_stop_instance_action_test.go:328: Progress: EC2 instance i-04068524d01beb19b has been successfully stopped
--- PASS: TestAccEC2StopInstanceAction_basic (93.68s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ec2 99.190s
% make t T=TestAccCodeBuildStartBuildAction_ K=codebuild
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 f-polling-library-for-actions 🌿...
TF_ACC=1 go1.24.6 test ./internal/service/codebuild/... -v -count 1 -parallel 20 -run='TestAccCodeBuildStartBuildAction_' -timeout 360m -vet=off
2025/09/30 17:16:16 Creating Terraform AWS Provider (SDKv2-style)...
2025/09/30 17:16:16 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccCodeBuildStartBuildAction_basic
=== PAUSE TestAccCodeBuildStartBuildAction_basic
=== RUN TestAccCodeBuildStartBuildAction_withEnvironmentVariables
=== PAUSE TestAccCodeBuildStartBuildAction_withEnvironmentVariables
=== CONT TestAccCodeBuildStartBuildAction_basic
=== CONT TestAccCodeBuildStartBuildAction_withEnvironmentVariables
--- PASS: TestAccCodeBuildStartBuildAction_withEnvironmentVariables (62.24s)
--- PASS: TestAccCodeBuildStartBuildAction_basic (62.26s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/codebuild 67.772s
% make t T=TestAccCloudFrontCreateInvalidationAction_basic K=cloudfront
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 f-polling-library-for-actions 🌿...
TF_ACC=1 go1.24.6 test ./internal/service/cloudfront/... -v -count 1 -parallel 20 -run='TestAccCloudFrontCreateInvalidationAction_basic' -timeout 360m -vet=off
2025/09/30 16:57:24 Creating Terraform AWS Provider (SDKv2-style)...
2025/09/30 16:57:24 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccCloudFrontCreateInvalidationAction_basic
=== PAUSE TestAccCloudFrontCreateInvalidationAction_basic
=== CONT TestAccCloudFrontCreateInvalidationAction_basic
--- PASS: TestAccCloudFrontCreateInvalidationAction_basic (449.17s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/cloudfront 454.859s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀.
Warning This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
This functionality has been released in v6.16.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Description
Introduces a new internal
actionwait
package: a lightweight, action-focused polling helper tailored for asynchronous AWS operation actions (e.g., EC2 stop, CloudFront invalidation, CodeBuild build) where we need deterministic status progression tracking and periodic user-facing progress updates without the heavier resource lifecycle semantics ofretry.StateChangeConf
.It provides a clear state taxonomy (success, transitional, failure, unexpected), pluggable interval strategies including fixed intervals and backoff integration via a bridge adapter to
internal/backoff
for sophisticated delay algorithms, throttled progress callbacks decoupled from poll cadence, typed errors (TimeoutError
,FailureStateError
,UnexpectedStateError
) with dedicated helper functions for error type checking, and optional typed payloads via generics to return rich SDK objects without wrappers.The package is organized into separate files (
wait.go
for core logic,errors.go
for error types and helpers) for better maintainability. This refactor reduces duplicated bespoke loops (deadline math, sleep, transitional guards), improves safety by uniformly surfacing unexpected states, provides flexible polling strategies (fixed for predictable operations like EC2 instance transitions, backoff for variable-duration operations like CodeBuild), and future‑proofs consecutive success handling.Comprehensive unit tests cover validation, success after transitions, failures, unexpected states, timeout, context cancel, fetch errors, progress throttling, consecutive success logic, and backoff adapter integration, ensuring behavior is well specified and stable for current and upcoming action implementations.
Relations
aws_ec2_stop_instance
#43700aws_cloudfront_create_invalidation
#43955aws_codebuild_start_build
#44444aws_transcribe_start_transcription_job
#44445References
Output from Acceptance Testing