Skip to content

fix: persist guided deploy args to samconfig.toml on failure#9140

Open
ljacobsson wants to merge 2 commits into
aws:developfrom
ljacobsson:fix/guided-deploy-save-samconfig-on-failure
Open

fix: persist guided deploy args to samconfig.toml on failure#9140
ljacobsson wants to merge 2 commits into
aws:developfrom
ljacobsson:fix/guided-deploy-save-samconfig-on-failure

Conversation

@ljacobsson

@ljacobsson ljacobsson commented Jul 22, 2026

Copy link
Copy Markdown

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 to samconfig.toml after 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:

  • No existing samconfig.toml (new project): answers are always saved on failure, since there is nothing to overwrite.
  • Existing 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-failure flag.

Successful deploys continue to save the config exactly as before.

What side effects does this change have?

  • A new --save-params-on-failure/--no-save-params-on-failure flag on sam deploy (default off), only relevant to --guided.
  • On a failed guided deploy of a brand-new project, a samconfig.toml will now be written where previously none was. The original error is still surfaced.
  • schema/samcli.json regenerated for the new option.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Review the generative AI contribution guidelines
  • Add input/output type hints to new functions/methods
  • [n/a] Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • [n/a] Write/update integration tests
  • [n/a] Write/update functional tests if needed
  • make pr passes
  • [n/a] make update-reproducible-reqs if dependencies were changed
  • [] Write documentation
    Documentation: 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.

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.
@github-actions github-actions Bot added area/deploy sam deploy command area/schema JSON schema file pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jul 22, 2026
@ljacobsson
ljacobsson marked this pull request as ready for review July 22, 2026 20:50
@ljacobsson
ljacobsson requested a review from a team as a code owner July 22, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deploy sam deploy command area/schema JSON schema file pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write to samconfig.toml sooner

1 participant