feat(toolkit-lib): configurable stack stabilization polling interval on deploy, destroy and prepareStack#1724
Merged
mrgrain merged 3 commits intoJul 10, 2026
Conversation
…ation polling stabilizeStack() in cfn-api.ts (via waitForStackDeploy()/waitForStackDelete()) polls DescribeStacks every 5s per in-flight stack to detect a terminal state, and the interval was hardcoded with no option threading to it. Programmatic consumers who already slowed the event monitor via stackEventPollingInterval (aws#1710) saw DescribeStacks from this stabilization loop become the dominant CloudFormation read-API caller instead. Reuse the existing stackEventPollingInterval option to also govern the stabilization polling interval, threading it through deployStack/destroyStack and Deployments.cleanupChangeSet to stabilizeStack. Default is unchanged (5000ms) when the option is unset. Not included: the rollback path (Deployments.rollbackStack), which calls stabilizeStack directly. This is the same rollback monitor aws#1710 deferred for event polling, so it's left out here for consistency and can be a follow-up. Closes aws#1723
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1724 +/- ##
=======================================
Coverage 89.59% 89.59%
=======================================
Files 77 77
Lines 11758 11758
Branches 1651 1651
=======================================
Hits 10534 10534
Misses 1195 1195
Partials 29 29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mrgrain
requested changes
Jul 10, 2026
Fold the stabilization-polling mention into the main sentence instead of appending it as a separate "Also governs..." addendum, per review feedback.
auto-merge was automatically disabled
July 10, 2026 12:00
Head branch was pushed to by a user without write access
mrgrain
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1723
Motivation
Follow-on to #1709/#1710, which made the
StackActivityMonitorevent-polling interval (DescribeStackEvents) configurable viastackEventPollingInterval. There's a second hardcoded polling loop that wasn't touched: the stabilization waiter.stabilizeStack()inlib/api/deployments/cfn-api.ts— via the exportedwaitForStackDeploy()/waitForStackDelete()— calls the module-privatewaitFor(valueProvider, timeout = 5000), pollingDescribeStacksevery 5s per in-flight stack to detect a terminal state, with no option threading to it.Programmatic consumers running large CI matrices who already slowed the event monitor via
stackEventPollingIntervalsawDescribeStacksfrom this stabilization loop become the dominant CloudFormation read-API caller instead, still triggering throttling.Design decision: one parameter, not two
stackEventPollingIntervalnow governs both the event-polling and stabilization-polling intervals, rather than adding a new sibling parameter (e.g.stackStabilizationPollingInterval). Going with reuse over a second parameter to avoid growing the public options surface onDeployOptions/DestroyOptionsfor a distinction most consumers won't need to control separately — both loops exist to reduceDescribeStack*call volume against the same CloudFormation rate limit. Happy to split it into a separate parameter in a follow-up if maintainers would rather keep the two tunable independently.Changes
stabilizationPollingInterval/pollingIntervalparameter towaitForStackDelete(),waitForStackDeploy(), andstabilizeStack()incfn-api.ts. Default unchanged (5000ms).stackEventPollingIntervaloption through to that new parameter — it already sits right beside thewaitForStackDeploy/waitForStackDeletecalls indeploy-stack.ts(deploy, destroy, and the delete-before-recreate path).deployStack()/destroyStack()indeploy-stack.ts(all three call sites: delete-before-recreate, post-deploy stabilization, post-destroy stabilization)Deployments.cleanupChangeSet()(the change-set cleanup path, called fromprepareStack()and fromToolkit.deploy()when a user declines the deploy confirmation prompt)stackEventPollingIntervalat each layer (DeployOptions,DestroyOptions,DeployStackOptionsin bothdeploy-stack.tsanddeployments.ts) to note it also governs stabilization polling.stackEventPollingIntervalalready existed; only its scope of effect changed, and doc comments were updated to reflect that.Not included
Per the issue, two call sites needed confirming during implementation:
waitForStackDeletefromDeployments.cleanupChangeSet— included (see above).Deployments.rollbackStack), which callsstabilizeStackdirectly — deferred. This is the same rollback monitor that feat(toolkit-lib): configurable stack event polling interval on deploy and destroy #1710 explicitly deferred for event polling, so leaving it out here keeps this PR consistent with that scope. Happy to addstackEventPollingIntervalsupport toRollbackStackOptionsin a follow-up if maintainers want it included.Testing
cfn-api-stabilization-polling-interval.test.ts: directly exercisesstabilizeStack,waitForStackDeploy, andwaitForStackDeletewith fake timers, assertingDescribeStackspolling cadence at both the 5s default and a custom interval.deploy-stack-polling-interval.test.ts: assertsdeployStack()/destroyStack()forwardstackEventPollingIntervaltowaitForStackDeploy/waitForStackDeleteas the stabilization interval, alongside the existingStackActivityMonitorassertions.cloudformation-deployments.test.ts: assertsprepareStack()forwardsstackEventPollingIntervalthroughcleanupChangeSet()towaitForStackDelete.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license