fix: persist guided deploy args to samconfig.toml on failure#9140
Open
ljacobsson wants to merge 2 commits into
Open
fix: persist guided deploy args to samconfig.toml on failure#9140ljacobsson wants to merge 2 commits into
ljacobsson wants to merge 2 commits into
Conversation
Save guided prompt answers even when the deploy fails (e.g. bad credentials), so they aren't lost. New projects always save on failure; when a samconfig already exists it's preserved unless --save-params-on-failure is passed.
ljacobsson
marked this pull request as ready for review
July 22, 2026 20:50
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.
Which issue(s) does this change fix?
Fixes #3693
Why is this change necessary?
When running
sam deploy --guided, the answers entered during the guided prompts are only written tosamconfig.tomlafter the credential-requiring AWS calls (manage_stack/sync_ecr_stack) succeed. If those calls fail (e.g. invalid or expired SSO credentials), the command aborts before saving, so the user has to re-enter every prompt after fixing their credentials. This is especially painful for stacks with many parameters (see #3693).How does it address the issue?
All config-relevant answers are now collected on the instance before any AWS call is made, and the config is saved even when the guided flow fails.
To avoid clobbering a known-good configuration during development (the concern raised in the issue discussion), save-on-failure is gated:
samconfig.toml(new project): answers are always saved on failure, since there is nothing to overwrite.samconfig.toml: the file is left untouched on failure by default. Users can opt in to overwriting it with the new--save-params-on-failure/--no-save-params-on-failureflag.Successful deploys continue to save the config exactly as before.
What side effects does this change have?
--save-params-on-failure/--no-save-params-on-failureflag onsam deploy(default off), only relevant to--guided.samconfig.tomlwill now be written where previously none was. The original error is still surfaced.schema/samcli.jsonregenerated for the new option.Mandatory Checklist
PRs will only be reviewed after checklist is complete
make prpassesmake update-reproducible-reqsif dependencies were changedDocumentation: the new --save-params-on-failure flag is documented via its --help text and the regenerated schema/samcli.json.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.