feat(ops): automated ephemeral stack cleanup script#109
feat(ops): automated ephemeral stack cleanup script#109scottschreckengaust wants to merge 3 commits into
Conversation
Shell script that identifies and deletes orphaned ABCA ephemeral CloudFormation stacks. Handles stuck ENI cleanup (Lambda/AgentCore Hyperplane ENIs) before stack deletion, respects termination protection, and supports dry-run mode. Closes #72 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Security/robustness review of scripts/cleanup-ephemeral-stacks.sh (#72): - Fail CLOSED on unparseable CreationTime. Previously a parse failure fell back to epoch 0, making every matching stack look ~billions of seconds old and eligible for deletion — the age gate failed open. Now it SKIPs. - Validate --max-age-hours is a non-negative integer before arithmetic (rejects injected/garbage input). - Print account + caller ARN (sts:GetCallerIdentity) before any action so the operator can confirm blast radius; hard-fail if identity can't be resolved. - Tolerate a single delete-stack failure instead of aborting the whole loop under set -e (would otherwise orphan later stacks); track and report a Failed count, and only increment Deleted on a delete actually initiated. - Remove dead --force-eni flag (parsed but never used; shellcheck SC2034). - Annotate the JMESPath --query backticks as intentional (shellcheck SC2016). shellcheck: clean (exit 0). semgrep --config=auto: 0 findings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Revived this branch: rebased onto latest Security/robustness review — ran
Scope unchanged: still the manual script only (Part of #72). EventBridge schedule, CloudWatch audit, CDK construct, and tests are deferred to a future PR. |
|
Follow-up filed: #278 — add |
Summary
scripts/cleanup-ephemeral-stacks.sh— a shell script that identifies and deletes orphaned ABCA ephemeral CloudFormation stacksDELETE_FAILEDstates--dry-run,--max-age-hours,--prefixfilter, and--force-enioptionsStatus
Script only — this is the operational cleanup tool from Issue #72. Still needed for full issue completion:
The script itself is complete and production-ready for manual use today.
Test plan
--dry-runagainst an account with ephemeral stacks--max-age-hoursfiltering is correctPart of #72 — this PR delivers the manual cleanup script foundation only. Full issue completion (EventBridge schedule, CloudWatch audit, CDK construct, tests) lands in a future PR.
🤖 Generated with Claude Code