autoscaling-lifecycle-operator
Operates EC2 Auto Scaling lifecycle hook workflows end-to-end — launch lifecycle hook management (pending:wait transition, bootstrap registration, ELB target registration, custom action execution), terminate lifecycle hook management (terminating:wait transition, ELB deregistration, session drain, graceful shutdown), HeartbeatTimeout management (default 3600s, heartbeat extension via record-lifecycle- action-heartbeat), Lambda/EventBridge integration for lifecycle actions (complete-lifecycle-action invocation contract), warm pool configuration (MinSize, MaxGroupPreparedCapacity, pool state transitions), standby state and instance protection, CloudWatch alarm-based scaling policies, scheduled actions, capacity rebalance integration for Spot interruptions, and lifecycle hook notification targets (SNS/SQS/Lambda /EventBridge). Runs deterministic pre-checks (hook existence, IAM passrole, notification target ARN validity, HeartbeatTimeout bounds, Lambda complete-lifecycle-action IAM grant, warm pool capacity...
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-24
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- autoscaling-lifecycle-operator
- license
- Apache-2.0
- metadata
- { "tags": "aws, autoscaling, compute, lifecycle, ec2, warm-pool, spot, elb, lambda, eventbridge, operate", "phase": "4", "author": "Jacky Chan — AWS Community Builder", "domain": "aws-cloudops", "family": "Compute", "version": "0.1.0", "keywords": "Auto Scaling, lifecycle hook, launch lifecycle hook, terminate lifecycle hook, HeartbeatTimeout, DefaultResult, CONTINUE, ABANDON, complete-lifecycle-action, record-lifecycle-action-heartbeat, pending:wait, Pending:Wait, Terminating:Wait, InService, warm pool, warm pool MinSize, MaxGroupPreparedCapacity, warm pool state, capacity rebalance, instance protection, standby, EnterStandby, ExitStandby, graceful drain, ELB deregistration, target group deregistration, connection drain, session drain, scheduled action, scaling policy, CloudWatch alarm, step scaling, target tracking, Spot Instance Interruption, SNS notification, SQS notification, EventBridge, lifecycle Lambda, bootstrap registration", "task_type": "operate", "complexity": "high", "entry_point": "false", "skill_class": "capability", "when_to_use": "Adding or modifying launch/terminate lifecycle hooks, debugging stuck lifecycle instances (pending:wait or terminating:wait), configuring warm pools for faster scale-out, wiring graceful-drain Lambdas for ELB deregistration and session drain, setting instance protection or standby state, integrating capacity rebalance with Spot interruptions, creating scheduled actions or CloudWatch alarm-based scaling policies, or routing lifecycle notifications to SNS/SQS/Lambda.", "requires_llm": "true", "verdict_shape": "OPERATION_COMPLETED | REVIEW_REQUIRED", "when_not_to_use": "EC2 instance-level OS patching or application deployment (use an SSM or CodeDeploy skill), ECS/Fargate service autoscaling (use an ECS autoscaling skill), Auto Scaling group creation from scratch (use a provisioning skill), or cost optimization of EC2 fleets (use an EC2 rightsizing skill). This skill focuses on lifecycle hook operations and warm pool management, not fleet provisioning or cost optimization.", "lifecycle_status": "active", "invocation_schema": "Input: either (a) an Auto Scaling group configuration (describe-auto- scaling-groups output) plus the intended operation (add-launch-hook, add-terminate-hook, modify-hook, delete-hook, configure-warm-pool, set-protection, enter-standby, exit-standby, add-scheduled-action, add-scaling-policy, enable-capacity-rebalance, diagnose-stuck), OR (b) an ASG name + operation for live-account execution. Output: a deterministic OPERATION / VERDICT / PRE_CHECKS / STEPS / POST_VERIFY / NOTES block per lifecycle operation, where VERDICT is one of OPERATION_COMPLETED, REVIEW_REQUIRED.", "supports_pipeline": "true", "activation_triggers": "add lifecycle hook, launch lifecycle hook, terminate lifecycle hook, lifecycle hook timeout, HeartbeatTimeout, complete-lifecycle-action, stuck lifecycle instance, pending wait stuck, terminating wait stuck, warm pool configuration, warm pool MinSize, capacity rebalance, graceful drain, ELB deregistration lifecycle, session drain, instance protection, standby state, enter standby, exit standby, scheduled action autoscaling, scaling policy, CloudWatch alarm scaling, Spot interruption lifecycle, SNS lifecycle notification, SQS lifecycle notification, EventBridge lifecycle, lifecycle Lambda, bootstrap on launch" }
- description
- Operates EC2 Auto Scaling lifecycle hook workflows end-to-end — launch lifecycle hook management (pending:wait transition, bootstrap registration, ELB target registration, custom action execution), terminate lifecycle hook management (terminating:wait transition, ELB deregistration, session drain, graceful shutdown), HeartbeatTimeout management (default 3600s, heartbeat extension via record-lifecycle- action-heartbeat), Lambda/EventBridge integration for lifecycle actions (complete-lifecycle-action invocation contract), warm pool configuration (MinSize, MaxGroupPreparedCapacity, pool state transitions), standby state and instance protection, CloudWatch alarm-based scaling policies, scheduled actions, capacity rebalance integration for Spot interruptions, and lifecycle hook notification targets (SNS/SQS/Lambda /EventBridge). Runs deterministic pre-checks (hook existence, IAM passrole, notification target ARN validity, HeartbeatTimeout bounds, Lambda complete-lifecycle-action IAM grant, warm pool capacity...
- compatibility
- Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline plan classification. Live-account operations use aws autoscaling describe-lifecycle-hooks, put-lifecycle- hook, delete-lifecycle-hook, complete-lifecycle-action, record-lifecycle- action-heartbeat, describe-warm-pool, put-warm-pool, describe-auto- scaling-groups, update-auto-scaling-group, set-instance-protection, enter-standby, exit-standby, put-scheduled-action...
02 资源文件 19
- 参考文档eval/test-cases.yaml8.1 KB
- 参考文档evals/baselines/capacity-rebalance-enable-completed.md529 B
- 参考文档evals/baselines/diagnose-stuck-pending-wait-review-required.md724 B
- 参考文档evals/baselines/launch-hook-bootstrap-ready.md670 B
- 参考文档evals/baselines/terminate-hook-spot-timeout-review-required.md716 B
- 参考文档evals/baselines/warm-pool-fast-scale-out-completed.md474 B
- 参考文档evals/eval_config.yaml1.9 KB
- 参考文档evals/evals.json4.4 KB
- 参考文档evals/prompts/capacity-rebalance-enable-completed.md928 B
- 参考文档evals/prompts/diagnose-stuck-pending-wait-review-required.md1.1 KB
- 参考文档evals/prompts/launch-hook-bootstrap-ready.md1.3 KB
- 参考文档evals/prompts/terminate-hook-spot-timeout-review-required.md793 B
- 参考文档evals/prompts/warm-pool-fast-scale-out-completed.md883 B
- 参考文档examples/README.md5.9 KB
- 参考文档references/advanced-patterns.md5.4 KB
- 参考文档references/diagnostic-procedures.md12.6 KB
- 参考文档references/lifecycle-hook-patterns.md11.8 KB
- 参考文档references/worked-examples.md1.1 KB
- 参考文档skill.usf.yaml4.5 KB
03 SKILL.md 正文
Auto Scaling Lifecycle Hook Operator
What this skill does
Executes EC2 Auto Scaling lifecycle hook operations correctly and safely.
Runs deterministic pre-checks before any state-changing CLI (hook existence,
HeartbeatTimeout bounds, notification target ARN validity, IAM passrole for
service-linked role, Lambda complete-lifecycle-action grant, warm pool
capacity headroom, ELB target group health), executes the operation behind
a CONFIRM gate, and verifies the result by confirming the hook is active,
lifecycle transitions complete within the expected window, and no instances
remain stuck in Pending:Wait or Terminating:Wait.
Quick navigation
| Section | What it covers | When to read it |
|---|---|---|
| Quick reference | Verdict thresholds + pre-check priority | Before any operation |
| Mindset | Why lifecycle hooks extend the transition, the stuck-instance trap | Understanding the safety model |
| Pre-flight | ASG metadata gate — hook config, warm pool state, notification targets | Before executing any CLI |
| Process | Per-operation planning: add-hook, warm-pool, diagnose-stuck | When choosing which operation |
| Output format | Structured OPERATION/VERDICT/PRE_CHECKS/STEPS template | Formatting the response |
| Anti-Patterns | NEVER list — common mistakes that strand instances | Review before risky operations |
Quick reference — verdict thresholds
| Verdict | Trigger condition | Action |
|---|---|---|
REVIEW_REQUIRED |
One or more pre-checks failed (hook missing required notification target, HeartbeatTimeout outside 30-7200s, Lambda lacks complete-lifecycle-action IAM grant, warm pool MaxGroupPreparedCapacity < MinSize, capacity rebalance conflicts with lifecycle hook) | List failures, do NOT execute |
OPERATION_COMPLETED |
Operation finished and post-verification passed (hook Active, lifecycle transition completed, warm pool at desired capacity, no instances stuck) | Emit verification results, monitoring plan |
Priority order for pre-checks (apply in this sequence):
- ASG existence and state — group exists, not being deleted, has a launch template/version.
- Hook configuration — no conflicting hook with the same name.
- HeartbeatTimeout bounds — between 30 and 7200 seconds (default 3600).
- Notification target validity — SNS/SQS/Lambda ARN exists and is
active. SNS/SQS requires the ASG service-linked role to have
sns:Publishorsqs:SendMessage. - IAM passrole —
AWSServiceRoleForAutoScalingexists with required permissions. - Lambda complete-lifecycle-action grant — lifecycle Lambda execution
role has
autoscaling:CompleteLifecycleActionon the ASG ARN. - Warm pool capacity —
MaxGroupPreparedCapacity>=MinSizeand <= ASGMaxSize. - ELB integration — target group deregistration delay compatible with terminate hook HeartbeatTimeout.
- Capacity rebalance — if enabled, terminate hooks must complete within the Spot 2-minute rebalance window.
Time baselines (2026):
- Launch hook: adds
HeartbeatTimeoutseconds toPending:Wait->InService. With 300s hook and 60s bootstrap, total is 300s (bootstrap runs within the wait window). - Terminate hook: adds
HeartbeatTimeoutseconds toTerminating:Wait->Terminated. ELB deregistration drain runs concurrently with the hook. - Warm pool: pre-booted
Stoppedinstances resume toRunningin ~10-30s (vs. 60-120s cold launch). - Capacity rebalance: rebalance recommendation + 2-min interruption notice gives ~4 min total; terminate hook must complete within this window.
Mindset
One-line takeaway: A lifecycle hook extends the instance state
transition by HeartbeatTimeout seconds. During this window, the instance
stays in Pending:Wait or Terminating:Wait and the action Lambda must
call complete-lifecycle-action before the timeout expires or the
DefaultResult (CONTINUE or ABANDON) determines the outcome.
-
A lifecycle hook is a timer, not a gate. The hook gives a window to do work (bootstrap, drain) but does not block forever. If the Lambda never calls
complete-lifecycle-action, the hook expires afterHeartbeatTimeoutandDefaultResultfires: CONTINUE (proceed) or ABANDON (for launch: terminate and replace; for terminate: terminate anyway). A Lambda that silently fails without completing is the #1 cause of stuck instances. -
Warm pool changes the scale-out math. Without a warm pool, a new instance takes 60-120 seconds (AMI boot + userdata + app startup). With a warm pool, pre-booted
Stoppedinstances resume toRunningin 10-30 seconds. But the launch lifecycle hook still fires on every transition from warm pool to the ASG — the hook Lambda must handle warm-pool- sourced instances (they already have the OS booted). -
Capacity rebalance + terminate hook is a race against the Spot clock. When Spot capacity is at risk, EC2 sends a rebalance recommendation followed by a 2-minute interruption notice. The ASG (with capacity rebalance) launches a replacement and starts draining the old instance via the terminate hook. The terminate hook HeartbeatTimeout must be short enough to complete within the interruption window (default 3600s is too long for Spot — use 30-120s).
Pre-flight: ASG metadata gate
Run before classification. Misclassifying these produces wrong plans.
Pagination: describe-auto-scaling-groups paginates at 50/page.
describe-lifecycle-hooks returns all hooks in one call. describe-warm- pool paginates at 100 instances/page.
Live-account pre-flight commands moved to references/diagnostic-procedures.md. Load that file before executing against a live account.
Malformed input: emit VERDICT: ERROR with REASON: ASG/operation configuration is not valid JSON or is missing required fields and
REMEDIATION: Re-fetch with aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names <name> --output json.
| ASG attribute | Effect on operation |
|---|---|
| ASG not found | All operations BLOCKED. |
MixedInstancesPolicy with Spot |
Capacity rebalance likely enabled; terminate hooks must be short (30-120s). |
| No lifecycle hooks configured | Add-hook operations proceed; diagnose-stuck returns "no hooks". |
| Existing hook with same name | Add-hook BLOCKED; use modify-hook. |
HeartbeatTimeout outside 30-7200 |
Invalid; put-lifecycle-hook will fail. |
NotificationTargetARN null or invalid |
Lambda never invoked; hook is a no-op timer. |
Warm pool MaxGroupPreparedCapacity < PoolMinSize |
Invalid configuration. |
TargetGroupARNs present |
ELB deregistration delay interacts with terminate hook timeout. |
HealthCheckType: ELB with short HealthCheckGracePeriod |
Launch hook must complete before grace period or ELB marks instance unhealthy. |
CapacityRebalance: true |
Terminate hook fires on rebalance + interruption; must complete within Spot 2-min notice. |
Process — operation planning (apply in order)
Step 0: Expert knowledge — non-obvious Auto Scaling lifecycle behaviors
Deep dive moved to references/advanced-patterns.md (Step 0: non-obvious lifecycle behaviors) — load before complex hook/warm-pool decisions.
Step 1: Pre-check gate — REVIEW_REQUIRED if any check fails
For ALL operations: ASG exists, has a launch template, not being deleted.
For add-launch-hook: No existing hook with same name.
HeartbeatTimeout in [30, 7200]. DefaultResult is CONTINUE or ABANDON.
NotificationTargetARN is valid and active. If SNS/SQS: service-linked
role has sns:Publish or sqs:SendMessage. If Lambda: execution role has
autoscaling:CompleteLifecycleAction. If ELB: HealthCheckGracePeriod
= expected bootstrap duration.
RoleARNhas trust policy forautoscaling.amazonaws.com.
For add-terminate-hook: Same as launch plus: if capacity rebalance
enabled, HeartbeatTimeout <= 120. If ELB target groups:
deregistration_delay.timeout_seconds <= HeartbeatTimeout.
For modify-hook: Hook exists. New HeartbeatTimeout in [30, 7200].
New notification target passes validity checks.
For delete-hook: Hook exists. No instances currently in
Pending:Wait or Terminating:Wait for this hook.
For configure-warm-pool: PoolMinSize >= 0.
MaxGroupPreparedCapacity >= PoolMinSize and <= ASG MaxSize.
DesiredCapacity + PoolMinSize does not exceed account vCPU limits or
subnet IP availability. Launch template supports Stop/Start.
For set-protection: Instances are members of the ASG and InService.
For enter-standby / exit-standby: Instances are members; for enter:
InService with ShouldDecrementDesiredCapacity specified; for exit: in
Standby.
For add-scheduled-action: No existing action with same name. Recurrence
is valid cron. MinSize <= DesiredCapacity <= MaxSize.
For add-scaling-policy: No existing policy with same name. Target
tracking: TargetValue > 0. Step scaling: alarm exists or will be created.
For enable-capacity-rebalance: ASG has Spot instances. Existing
terminate hooks have HeartbeatTimeout <= 120.
For diagnose-stuck (read-only): Read hook state, CloudWatch Logs, and the stuck-instance table to identify root cause.
Stuck-instance failure-mode table:
| Symptom | Root cause | Fix |
|---|---|---|
Pending:Wait > HeartbeatTimeout |
Lambda never called complete-lifecycle-action | Check Lambda logs; call complete manually |
Pending:Wait, Lambda AccessDenied on CompleteLifecycleAction |
Lambda role missing permission | Add autoscaling:CompleteLifecycleAction to role |
Terminating:Wait > HeartbeatTimeout |
Same as above for terminate | Same fix |
Pending:Wait, Lambda never invoked |
EventBridge rule missing or SNS unconfirmed | Check rule pattern; confirm SNS subscription |
Pending:Wait, event missing LifecycleActionToken |
EventBridge rule wrong detail type | Match EC2 Instance-launch Lifecycle Action |
Warm pool instance stuck in Pending:Wait |
Lambda not designed for warm pool | Update Lambda to detect warm-pool instances |
| Instance terminated despite terminate hook | Spot force-kill; HeartbeatTimeout was 3600s | Reduce to <= 120 for Spot ASGs |
put-lifecycle-hook ValidationError |
HeartbeatTimeout outside 30-7200 or malformed ARN | Correct parameters |
| Multiple hooks, instance stuck between hooks | Each hook must complete before next | Reduce hooks or shorten timeouts |
Step 2: READY — emit operation plan
If all pre-checks pass, emit VERDICT: READY with the exact CLI sequence
and CONFIRM gate. The plan includes the exact CLI command, expected
duration, side-effects, CONFIRM prompt, and monitoring step.
Step 3: Execute behind CONFIRM gate
- MANDATORY CONFIRMATION GATE. Before any state-changing CLI
(
put-lifecycle-hook,delete-lifecycle-hook,complete-lifecycle- action,put-warm-pool,set-instance-protection,enter-standby,exit-standby,put-scheduled-action,put-scaling-policy,update-auto-scaling-group), emitCONFIRM: About to <operation> on <asg-name> in account <account> region <region>. This will <consequence>. Proceed? (yes/no). - Capture pre-state:
describe-lifecycle-hooksanddescribe-auto-scaling- groupsoutput saved to/tmp/<asg>-*-$(date +%s).json. - Execute the CLI. For
put-lifecycle-hook, the hook is immediately active. - For hooks with a Lambda:
aws logs tail /aws/lambda/<lifecycle-lambda> --follow --since 5m.
Step 4: Post-verification — OPERATION_COMPLETED
ALL checks must pass for OPERATION_COMPLETED:
describe-lifecycle-hooksconfirms hook with correct configuration.- For add/modify-hook: test scale-out confirms instance enters
Pending:Wait, Lambda fires, transitions toInService. - For configure-warm-pool:
describe-warm-poolconfirms correctPoolMinSize,MaxGroupPreparedCapacity, instances present. - For set-protection/standby: confirm instance state via
describe-auto-scaling-groups. - CloudWatch shows no lifecycle timeout errors (15-min sample).
If ANY verification fails, emit VERDICT: ERROR — route to diagnose-stuck.
Output format (per operation)
OPERATION: <add-launch-hook | add-terminate-hook | modify-hook | delete-hook | configure-warm-pool | set-protection | enter-standby | exit-standby | add-scheduled-action | add-scaling-policy | enable-capacity-rebalance | diagnose-stuck>
VERDICT: OPERATION_COMPLETED | REVIEW_REQUIRED
TARGET: <asg-name> (hook: <hook-name-or-"none">)
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command with flags populated>
2. <wait / monitoring command>
POST_VERIFY:
- [PASS] <verification description>
NOTES: <monitoring, caveats, warm pool state>
Worked example — add-launch-hook (bootstrap registration)
OPERATION: add-launch-hook
VERDICT: OPERATION_COMPLETED
TARGET: prod-web-asg (hook: web-bootstrap-hook)
PRE_CHECKS:
- [PASS] ASG exists, DesiredCapacity: 4, MaxSize: 20
- [PASS] No existing hook named web-bootstrap-hook
- [PASS] HeartbeatTimeout: 300 (in [30, 7200])
- [PASS] DefaultResult: CONTINUE
- [PASS] Lambda web-lifecycle-action State: Active
- [PASS] Lambda role has autoscaling:CompleteLifecycleAction
- [PASS] HealthCheckGracePeriod: 600 >= bootstrap 120s
STEPS:
1. CONFIRM: About to add launch lifecycle hook web-bootstrap-hook
on prod-web-asg with HeartbeatTimeout 300s, DefaultResult CONTINUE,
Lambda web-lifecycle-action. New instances enter Pending:Wait for
up to 300s during bootstrap. Proceed? (yes/no)
2. aws autoscaling put-lifecycle-hook \
--lifecycle-hook-name web-bootstrap-hook \
--auto-scaling-group-name prod-web-asg \
--lifecycle-transition autoscaling:EC2_INSTANCE_LAUNCHING \
--heartbeat-timeout 300 \
--default-result CONTINUE \
--notification-target-arn arn:aws:lambda:us-east-1:111111111111:function:web-lifecycle-action
POST_VERIFY:
- [PASS] describe-lifecycle-hooks: web-bootstrap-hook active
- [INFO] Test scale-out: instance entered Pending:Wait, Lambda invoked,
transitioned to InService in 87s
NOTES:
- If Lambda crashes, instance stays in Pending:Wait for 300s, then
DefaultResult CONTINUE fires. Monitor Lambda errors.
- For warm-pool instances, Lambda detects already-booted OS and
skips AMI-level bootstrap.
Worked example — diagnose-stuck (REVIEW_REQUIRED)
Full example moved to references/worked-examples.md. Load it when formatting a diagnose-stuck REVIEW_REQUIRED response.
Anti-Patterns — NEVER
-
NEVER set HeartbeatTimeout to 3600 (the default) without calculating the expected action duration. Set to 2-3x the expected bootstrap/drain time.
-
NEVER deploy a lifecycle Lambda without
autoscaling:CompleteLifecycleActionin its execution role. Without it, the Lambda cannot release the instance — the #1 cause of stuck instances. -
NEVER delete a lifecycle hook while instances are in
Pending:WaitorTerminating:Waitfor that hook. Deleting strands those instances. -
NEVER use a terminate hook with HeartbeatTimeout > 120 on a Spot ASG with capacity rebalance. The Spot 2-minute interruption notice force-terminates regardless of hook state.
-
NEVER configure
deregistration_delay.timeout_secondshigher than the terminate hook HeartbeatTimeout. The instance is terminated before drain completes. -
NEVER set
DefaultResult: ABANDONon a launch hook without a replacement strategy. ABANDON terminates on timeout and the ASG launches a replacement — which fires the same hook. Broken bootstrap = launch loop. Use CONTINUE (fail-open). -
NEVER set
HealthCheckGracePeriodshorter than the launch hook HeartbeatTimeout withHealthCheckType: ELB. The ELB health check runs on an instance still inPending:Wait, marks it unhealthy, ASG replaces. -
NEVER assume warm pool instances skip the launch lifecycle hook. They enter
Pending:Waitwhen claimed — the hook fires. The Lambda must handle warm-pool-sourced instances. -
NEVER set
MaxGroupPreparedCapacitybelowPoolMinSize— invalid,put-warm-poolreturnsValidationError. -
NEVER use
enter-standbywithout specifyingShouldDecrementDesiredCapacity. Without it the ASG launches a replacement for the standby instance. -
NEVER assume
set-instance-protectionprotects against Spot interruptions. Protection only prevents ASG-initiated scale-in. Spot interruptions and capacity rebalance bypass it. -
NEVER create multiple hooks with long HeartbeatTimeouts on the same transition without calculating the total. Two 300s hooks = up to 600s in
Pending:Wait. -
NEVER configure a lifecycle hook with no notification target. Without it, no action receives the event, and the instance sits until HeartbeatTimeout. This is a no-op hook that only adds latency.
-
NEVER assume the lifecycle event always contains
LifecycleActionToken. EventBridge retries or SNS misconfiguration may omit it. The Lambda should handle missing tokens gracefully. -
NEVER auto-execute a state-changing Auto Scaling CLI without the CONFIRM gate. These operations have production-wide side effects.
-
NEVER use a lifecycle hook as a deployment mechanism. Hooks are for instance-level initialization and drain, not application deployment. Use CodeDeploy, SSM, or a deployment pipeline.
Pre-flight safety checks
- MANDATORY CONFIRMATION GATE. Before any state-changing operation, emit the CONFIRM prompt. Do NOT execute until confirmed.
- Capture pre-state for rollback. Save
describe-lifecycle-hooksanddescribe-auto-scaling-groupsoutput before changes. - Verify Lambda state.
get-function-configuration— confirmState: ActiveandTimeout>= expected action duration. - Verify Lambda execution role. Confirm
autoscaling:CompleteLifecycleActionon the ASG ARN. - Verify notification target. SNS: topic exists with confirmed
subscriptions. SQS: queue exists with policy allowing
autoscaling.amazonaws.com. Lambda: EventBridge invocation permission. - Verify warm pool headroom.
describe-subnetsfor IP availability;get-service-quotafor vCPU limits. - Verify capacity rebalance interaction. If enabled, terminate hooks must have HeartbeatTimeout <= 120.
- Prefer additive changes. Adding hooks, configuring warm pools, and setting protection are reversible. Deleting a hook with active lifecycle actions is destructive.
Recent AWS features (2024-2026)
Feature notes moved to references/advanced-patterns.md. Load when deciding whether a recent feature changes the plan.
References (load on demand)
- references/lifecycle-hook-patterns.md — hook configuration matrix, notification targets, Lambda handler skeleton, IAM policies
- references/diagnostic-procedures.md — stuck-instance diagnostic procedures, command quick-reference, live-account pre-flight
- references/worked-examples.md — secondary worked example (diagnose-stuck, REVIEW_REQUIRED)
- references/advanced-patterns.md — Step-0 expert deep dive, recent AWS features
Domain
AWS CloudOps / EC2 Auto Scaling Lifecycle Hook Management, Warm Pool Configuration, and Capacity Rebalance Integration.
AWS documentation
- Auto Scaling User Guide — Lifecycle hooks — https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html
- Lifecycle hook overview — https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks-overview.html
- Tutorial: Lambda lifecycle hook — https://docs.aws.amazon.com/autoscaling/ec2/userguide/tutorial-lifecycle-hook-lambda.html
- Warm pools — https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-warm-pools.html
- Capacity rebalance — https://docs.aws.amazon.com/autoscaling/ec2/userguide/capacity-rebalance.html
- Auto Scaling API Reference — https://docs.aws.amazon.com/autoscaling/ec2/APIReference/Welcome.html
- Auto Scaling CLI Reference — https://docs.aws.amazon.com/cli/latest/reference/autoscaling/
- Scheduled actions — https://docs.aws.amazon.com/autoscaling/ec2/userguide/schedule_time.html
- Target tracking scaling — https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-target-tracking.html
- Instance protection — https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-protection.html
04 同仓库更多 Skills
xray-tracing-deployer
Deploys AWS X-Ray distributed tracing with production-grade configuration: X-Ray daemon deployment (EC2 systemd, ECS sidecar, EKS DaemonSet, Lambda built-in), SDK instrumentation (Java, Python, Node.js, Go, .NET) with annotations and metadata, sampling rules (default reservoir + rate vs custom rules with URL / method / service-name predicates), service map generation, trace query and retrieval, groups and insights, CloudWatch ServiceLens integration, IAM permissions (PutTraceSegments, GetSamplingRules), and latest features (Lambda Powertools tracing, OpenTelemetry / ADOT Collector support, W3C trace context). Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when enabling X-Ray on a new application, adding tracing to ECS / EKS / Lambda, validating a sampling configuration, or generating daemon deployment CLI and IaC templates. Triggers: X-Ray, distributed tracing, X-Ray daemon, sampling rules, service map, X-Ray SDK, OpenTelemetry, ADOT, Lambda Powertools, CloudWatch ServiceLens.
wellarchitected-workload-auditor
Audits AWS Well-Architected Tool workloads for review staleness, per-pillar high-risk issue counts, milestone tracking gaps, and remediation plan completeness. Emits a deterministic verdict (STALE_REVIEW | HIGH_RISK | CONFIG_GAP | OK) per workload with per-pillar risk breakdown, milestone trend analysis, and specific remediation. Use when reviewing Well-Architected workloads, checking WA review freshness, auditing high-risk issues per pillar, validating milestone coverage, or tracking remediation plans.
wellarchitected-review-operator
Operates AWS Well-Architected Tool reviews end-to-end — creates workloads, runs pillar reviews (operational excellence, security, reliability, performance, cost optimization, sustainability, Prosperity), answers questions with risk-tier rationale, generates reports and improvement plans, creates milestones, and integrates with Trusted Advisor and Well-Architected Labs. Runs deterministic pre-checks (workload existence, lens availability, pillar coverage), emits the exact update-answer / get-consolidated-report CLI behind a CONFIRM gate, and verifies risk-tier transitions. Emits READY | BLOCKED | COMPLETED. Use when creating a workload, answering pillar questions, generating an improvement plan, creating a milestone, or integrating with Trusted Advisor. Triggers: well-architected tool, well architected review, workload review, pillar, operational excellence, security, reliability, performance, cost optimization, sustainability, prosperity, improvement plan, milestone, trusted advisor.
wafv2-web-acl-deployer
Provisions AWS WAFv2 Web ACLs with correct production defaults: scope selection (CLOUDFRONT vs REGIONAL), managed rule groups (AWSManagedRulesCommonRuleSet, SQLiRuleSet, LinuxRuleSet, WindowsRuleSet, IPReputationList, BotControlRuleSet, AmazonIpReputationList, ATP), custom rules (byte match, IP set, regex pattern, geo match, size constraint, rate-based), rule priority ordering, logging destinations (Kinesis Firehose, CloudWatch Logs, S3), resource association (ALB, API Gateway, CloudFront), rate-based rules with aggregate keys (IP, forwarded IP), Challenge and CAPTCHA actions, and account takeover prevention. Emits a READY_TO_DEPLOY checklist. Use when creating a Web ACL, attaching managed rules, configuring rate limiting, enabling WAF logging, associating a Web ACL with an ALB/API Gateway/CloudFront, or configuring CAPTCHA/Challenge actions. Triggers: create WAF Web ACL, WAFv2, managed rule groups, WAF rate limiting, WAF logging, WAF CAPTCHA, WAF Challenge action, bot control, ATP managed rules.
wafv2-web-acl-auditor
Audits AWS WAFv2 Web ACL configurations to determine whether the ACL provides effective protection: default-action posture (Allow vs Block), managed-rule-group coverage gaps, rule effectiveness (BLOCK vs COUNT, shadow/bypass rules, stale exclusions), rate-based rule correctness, logging and visibility configuration, and text-transformation bypass vectors. Emits a deterministic verdict per Web ACL. Use when reviewing a WAFv2 Web ACL for security posture, checking managed-rule coverage, validating rate-limit configuration, auditing WAF logging, or hardening a WAF before production deployment. Triggers: WAF, WAFv2, Web ACL, managed rule group, AWSManagedRules, rate-based rule, CAPTCHA, Challenge, OverrideAction, Count mode, forwarded IP, Bot Control, ATP, text transformation, WAF logging, WAF visibility, OWASP, SQLi, XSS, RFI.
waf-rule-deployer
Provisions AWS WAFv2 rule sets with production defaults: Web ACL creation (CloudFront scope in us-east-1 vs Regional scope), rule groups (managed vs custom) with capacity planning in WCU (Web ACL Capacity Units, 1500 default per ACL), managed rule groups (AWSManagedRulesCommonRuleSet, AWSManagedRulesSQLiRuleSet, AWSManagedRulesAmazonIpReputationList, AWSManagedRulesLinuxRuleSet, AWSManagedRulesWindowsRuleSet, AWSManagedRulesUnixRuleSet), custom rules (byte-match, regex pattern set, geo-match, rate-based), IP set and regex pattern set resources, rule priority ordering (lowest number evaluated first), action types (allow, block, count, CAPTCHA, Challenge), bot control managed rule group, account takeover. Triggers: create WAF rule, WAF managed rule group, WAF custom rule, WAF byte match, WAF geo match, WAF rate based rule, WAF IP set, WAF regex pattern set, WAF WCU budget, WAF CloudFront ACL, WAF logging Kinesis Firehose, WAF bot control, WAF ATP, WAF label matching, WAF Challenge action, WAF CAPTCHA.