Skip to content

fix: update.sh --use-previous-parameters → per-param UsePreviousValue=true (U1, v20.5.3)#47

Merged
hyunsies merged 1 commit into
mainfrom
sprint6/pr47-update-sh-flag-fix
Apr 25, 2026
Merged

fix: update.sh --use-previous-parameters → per-param UsePreviousValue=true (U1, v20.5.3)#47
hyunsies merged 1 commit into
mainfrom
sprint6/pr47-update-sh-flag-fix

Conversation

@hyunsies
Copy link
Copy Markdown
Contributor

Summary

Severity: high. Every customer upgrade attempt with the PR-#26 Update-mode generator failed on first run. Closes U1 from the 2026-04-24 correctness sweep.

The generated update.sh invoked aws cloudformation update-stack and update-stack-set with --use-previous-parameters. That flag does not exist on either command in AWS CLI v2 (only --use-previous-template, which is a different thing). Customers got Unknown options: --use-previous-parameters immediately.

Fix

The generated script now:

  1. Calls describe-stack-set / describe-stacks with --query "...Parameters[].ParameterKey" to enumerate current parameter keys.
  2. Builds a --parameters ParameterKey=<K>,UsePreviousValue=true ... list dynamically.
  3. Passes that list in both call sites.

Newly-added template parameters (e.g. ReconciliationInterval from v20.5.0) are intentionally omitted from the --parameters list so CFN picks up the new template's Default — documented CFN behavior for omitted parameters during update-stack, correct for customers upgrading from pre-reconciliation to a template that adds it.

If the describe call returns empty (IAM misconfig edge case), the script aborts with a clear message rather than proceeding with an empty --parameters list.

Scope

  • configurator.html: new PARAM_KEYS enumeration helper + two emit-site fixes in editorGenerateUpgrade. VERSION_HISTORY v20.5.3 entry. Inline-comment stamps and UI-facing confirm-risk blurb updated. VERSION bump.
  • map2-auto-tagger-optimized.yaml: version bump only (v20.5.2v20.5.3 at 4 sites).
  • CHANGELOG.md + VERSIONING.md: v20.5.3 entries.

No runtime Lambda change. YAML byte-identical to v20.5.2 except version stamps.

Not in scope: the 7 non-English translations of ui_update_confirm_risk still reference the old --use-previous-parameters flag name. Copy-drift only, low severity — flagged in the commit body for a follow-up retranslation PR.

Test plan

Local (done):

  • sync-check.py passes
  • lint_cfn_correctness.py passes
  • lint_event_prefixes.py passes
  • lint_shell_injection.py passes (no U4 regression)
  • cfn-lint silent (clean)
  • Handler coverage unchanged (106/154)
  • JS template literal rendering verified via node.js — $(aws ...), $VARNAME, \\ all render as expected bash

CI (Layer 1 required):

  • CloudFormation Lint
  • Lambda Python Syntax
  • Handler Regression Check
  • Configurator HTML Check
  • EventBridge Prefix Parity
  • CFN Correctness

Next-time end-of-sprint Layer 2: includes a generate update.sh → run against test stack step today. Should catch regressions of this class if added.

🤖 Generated with Claude Code

…=true (U1, v20.5.3)

**Severity: high.** Every customer upgrade attempt failed on first run.

The bug: PR #26's Update-mode generator emitted update.sh with
`--use-previous-parameters` on both `aws cloudformation update-stack`
and `update-stack-set`. That flag does not exist in AWS CLI v2
(only `--use-previous-template`, a different thing). Customers ran
the generated update.sh and hit "Unknown options: --use-previous-parameters"
immediately.

The fix: the generated script now calls describe-stack-set /
describe-stacks first to enumerate current parameter keys, then
builds a `--parameters ParameterKey=<K>,UsePreviousValue=true ...`
list dynamically. Each existing parameter value is carried forward.

Newly-added template parameters (for example ReconciliationInterval
from v20.5.0) are intentionally OMITTED from the --parameters list
so CFN picks up the new template's Default — that is the documented
CFN behavior for omitted parameters during update-stack, and it is
the correct behavior for a customer upgrading from pre-reconciliation
to a template that adds it.

If the describe call returns an empty result (unlikely, but possible
if IAM is misconfigured), the script aborts with a clear error and
cleans up the tmp template file rather than proceeding with an empty
parameter list.

Inline-comment stamps and the UI-facing confirm-risk blurb updated
to reflect the new mechanism. The 7 non-English translations of the
confirm-risk blurb still mention the old flag name — low-severity
copy drift, flagged for a follow-up retranslation PR.

Scope: only the update.sh generator. deploy.sh, the in-place scope-
edit editor flow, and the YAML Lambda runtime are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyunsies hyunsies merged commit 22d854c into main Apr 25, 2026
15 checks passed
@hyunsies hyunsies deleted the sprint6/pr47-update-sh-flag-fix branch April 25, 2026 15:10
hyunsies added a commit that referenced this pull request Apr 25, 2026
* feat(configurator): delete.sh flow (v20.6.0)

New fourth configurator mode: "Delete existing deployment". Generates
delete.sh that cleanly removes MAP Auto-Tagger deployments. MINOR bump —
safe in-place upgrade (YAML runtime byte-identical to v20.5.4 except
four version stamps; adds new UI + new generated script only).

Implements items 2, 4, 5, 6, 8 of Jin's Wave-0 scope (PR #27):
- #2  Rename destroy → delete throughout (filename / UI / i18n keys /
      docs / internal JS)
- #4  Default UX is "delete ALL map-auto-tagger-mig* in region";
      opt-in checkbox reveals specific-MPE input
- #5  Staging-bucket handling is automatic: delete when no other
      deployments remain, retain otherwise (no opt-in checkbox)
- #6  Log-group opt-in kept (default off; audit history preserved)
- #8  Type-DELETE confirmation works for both "delete all" and
      "scope to MPE" paths

Flow: three-step (Configure → Review → Download), mirroring Deploy /
Editor / Upgrade. Generates delete-all.sh by default; delete-<mpe>-
<mpe>.sh when scoped. Script:
  - Enumerates map-auto-tagger-mig* Stacks and StackSets in region
  - For StackSets: deletes instances in parallel (100% tolerance), then
    the StackSet itself. 30-min wait ceiling.
  - For Stacks: delete-stack + wait
  - S3 staging bucket auto-decided — kept if any other deployment
    remains, deleted otherwise (race: simultaneous scoped deletes
    could both retain; accepted, same class as §1.108 TOCTOU)
  - Optional: delete matching CloudWatch Log Groups
  - NEVER deletes: map-migrated tags on AWS resources, StackSet admin /
    execution IAM roles (shared org scaffolding)
  - Legacy pre-namespacing stack detection — if no map-auto-tagger-mig*
    matches, probes for unnamespaced map-auto-tagger and emits manual-
    delete instructions instead of silent exit (same pattern as
    upgrade.sh v20.5.4)
  - Idempotent: missing resources = skipped (not failed); non-zero exit
    only on real failures

MPE-ID regex in UI is permissive (alphanumeric, any length ≤20) to
match the Lambda runtime's AllowedPattern ^mig[a-zA-Z0-9]+$. Will
tighten to ^mig[a-z0-9]{10}$ once H6 product call lands repo-wide.
Flagged as follow-up in CHANGELOG.

English-only for new i18n keys (ui_mode_delete_*, ui_delete_*,
err_delete_*); 7 non-English locales fall back to English via existing
t() behavior. Translation follow-up flagged; same pattern as
ui_update_confirm_risk (PR #47) and ui_upgrade_* (PR #48a).

E2E coverage deferred to a follow-up PR per Sprint 7 P3 mandate
(every generator output gets E2E before ship). The delete.sh harness
lives alongside the existing deploy.sh harness in .github/scripts/ —
separating the two PRs keeps both reviewable.

Layer 1 local: sync-check ✅, lint_cfn_correctness ✅,
lint_event_prefixes ✅, lint_shell_injection ✅, HTML well-formed ✅,
YAML Lambda py_compile ✅, cfn-lint ✅. Both script variants
(delete-all and scoped) render cleanly and pass `bash -n`.

Co-authored-by: Jin Shan Ng <ngjinshan99@gmail.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(configurator): MPE enforcement + i18n coverage in delete flow (v20.6.0)

Three fixes to the delete.sh flow before PR #49 merges:

1. MPE ID format enforcement now mirrors Editor/Update modes —
   DELETE_MPE_REGEX tightened from /^[a-zA-Z0-9]+$/ to the same
   10-char /^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]{10}$/ the other flows
   use. Invalid rows get red .error highlighting like updateReview().
2. MPE input auto-uppercases and strips non-[A-Z0-9] on keystroke,
   matching the editor/update inputs. maxlength also dropped from
   20 to 10 to reflect the real format.
3. Language switching mid-flow now re-renders the delete review
   table (dstep2) and the delete-instructions preview (dstep3) —
   previously only the main editor step2 and deploy step3 were
   re-rendered on language switch.

Also fills 31 missing delete-related i18n keys across ko/ja/zh/id/th/vi
(previously all fell through to English) and defines rv_enabled which
was referenced in deleteReview() but never in TRANSLATIONS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: chhyu-runner <noreply@anthropic.com>
Co-authored-by: Jin Shan Ng <ngjinshan99@gmail.com>
Co-authored-by: Chris Hyu <chhyu@amazon.com>
@hyunsies hyunsies mentioned this pull request Apr 25, 2026
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant