S3 Version Cleanup Operator
What this skill does
Executes S3 version cleanup operations correctly and safely — for
cost optimization and for compliance retention. Runs deterministic
pre-checks before any state-changing CLI (versioning state, Object
Lock mode + retention, legal holds, existing lifecycle conflicts),
executes the operation behind a CONFIRM gate, and verifies the
result. Every operation surfaces the estimated monthly savings, the
compliance implications, and the verification steps.
Quick navigation
| Section |
What it covers |
When to read it |
| § Quick reference |
Verdict thresholds (BLOCKED/READY/COMPLETED) + pre-check priority order |
Before any operation |
| § Mindset |
Why version cleanup is the #1 S3 cost lever, the 4 lifecycle rule types, Object Lock modes |
Understanding the cost model |
| § Pre-flight |
Bucket metadata gate — versioning state, Object Lock, legal holds, existing lifecycle |
Before executing any CLI |
| § Process |
Per-operation planning: lifecycle rules, batch-delete, impact estimation, audit |
When choosing which operation to run |
| § Output format |
Structured output template with VERDICT, COMMANDS, SAVINGS, VERIFICATION |
Formatting the response |
| § Anti-Patterns |
NEVER list — common mistakes that cause data loss or compliance violation |
Review before risky operations |
| § Pre-flight safety |
Additional checks before any remediation CLI |
Defense-in-depth |
Quick reference — verdict thresholds
| Verdict |
Trigger condition |
Action |
BLOCKED |
One or more pre-checks failed (versioning not enabled, Object Lock Compliance mode blocks deletion, legal hold active, lifecycle rule conflict, bucket in a different region/account than expected) |
List failures, do NOT execute |
READY |
All pre-checks passed; awaiting CONFIRM gate |
Emit exact CLI/JSON sequence, wait for operator yes |
COMPLETED |
Operation finished and post-verification passed (lifecycle rule applied, Batch Operations job completed, noncurrent version count dropped) |
Emit savings estimate, verification results |
Priority order for pre-checks (apply in this sequence, all must pass
for READY):
- Versioning state — must be
Enabled for cleanup to affect
noncurrent versions. Suspended is a different state (new puts
create a null-version-id object, old versions are preserved).
NeverEnabled → no versions exist, nothing to clean.
- Object Lock — if
Compliance mode is active with retention,
versions CANNOT be deleted or overwritten until retention expires
(not even by root). Governance mode permits deletion with
s3:BypassGovernanceRetention permission.
- Legal holds — per-object
LegalHold: ON prevents deletion
regardless of lifecycle, Object Lock mode, or retention. Check
via get-object-legal-hold for specific objects.
- Existing lifecycle rules —
put-bucket-lifecycle-configuration
REPLACES the entire configuration, not merges. Read existing
rules first and merge new rules; otherwise you silently delete
existing transitions/expirations.
- MFA Delete — if
MFADelete: Enabled on the bucket, version
deletion and lifecycle rule changes require MFA. Plan for the
additional auth step.
- Bucket Key —
BucketKeyEnabled: true reduces KMS request cost
on encrypted buckets (~99% reduction). Recommend enabling alongside
lifecycle changes.
Cost/savings baselines (2026 us-east-1):
- Standard storage: ~$0.023/GB-month.
- Standard-IA: ~$0.0125/GB-month (50% cheaper, but 30-day minimum +
retrieval fee).
- Glacier Instant Retrieval:
$0.004/GB-month (83% cheaper).
- Glacier Flexible Retrieval:
$0.0036/GB-month (84% cheaper).
- Glacier Deep Archive:
$0.00099/GB-month (96% cheaper).
- One-time delete via lifecycle or Batch Operations: free (no per-delete
charge).
- S3 Batch Operations: ~$1.00 per million objects processed.
Rule of thumb: versioned buckets with frequent overwrites
accumulate noncurrent versions at the same rate as the overwrite
frequency × object size. A 1 GB log file overwritten hourly = 24
noncurrent versions/day × $0.023/GB ≈ $0.55/month — scales linearly
with overwrite count.
Mindset
One-line takeaway: versioned buckets accumulate noncurrent versions
indefinitely at standard storage rates — version cleanup is the #1 S3
cost optimization after storage-class transitions. Driven by four
realities:
- Every noncurrent version bills at full Standard rate by default.
Unlike S3 IA or Glacier, noncurrent versions are NOT automatically
tiered. A 1 GB file overwritten 100 times is 100 GB of Standard
storage — 100x the cost of the current version alone.
- Object Lock Compliance mode is irrevocable. If Compliance mode is
active with retention until 2030, no one (including root, including
AWS support) can delete those versions before 2030. This is the
correct posture for ransomware-resilient backups — and a hard block
for version cleanup.
put-bucket-lifecycle-configuration REPLACES, not merges. Every
operator who forgets this silently deletes the existing lifecycle
rules — transitions, expirations, abort-multipart rules — and the
bucket reverts to "no lifecycle" until the operator notices (usually
via a cost spike months later).
- Legal holds override everything. A single
LegalHold: ON on one
object blocks its deletion regardless of Object Lock mode, retention,
lifecycle rules, or root access. Legal holds are per-object; bulk
cleanup requires checking each object (or using Batch Operations with
a manifest).
Pre-flight: bucket metadata gate
Run before classification. Misclassifying these produces wrong plans.
Pagination: list-object-versions paginates at 1000 keys/page —
drain --key-marker and --version-id-marker to completion. Use S3
Storage Lens for account-wide noncurrent version metrics instead of
enumerating every bucket.
Live-account pre-flight (skip if offline plan audit):
aws s3api get-bucket-versioning --bucket <name> — confirm
Status: Enabled. Capture MFADelete (if enabled, plan for MFA).
aws s3api get-bucket-lifecycle-configuration --bucket <name> —
capture existing rules. NEVER overwrite without first reading.
aws s3api get-object-lock-configuration --bucket <name> — capture
ObjectLockEnabled and Rule.DefaultRetention (Mode, Days, Years).
aws s3api get-public-access-block --bucket <name> — context only.
aws s3api get-bucket-encryption --bucket <name> — capture
BucketKeyEnabled (recommend enabling if false and SSE-KMS in use).
aws s3api list-object-versions --bucket <name --max-keys 1000 —
sample the noncurrent version count and average size for impact
estimation.
aws s3control get-storage-lens-configuration --config-id default
— capture account-level NoncurrentVersionCount and
NoncurrentVersionStorageBytes.
- For specific objects being cleaned:
aws s3api get-object-legal-hold --bucket <name> --key <key> --version-id <vid> — verify no legal
hold before batch-delete.
Malformed input: if the input JSON is invalid or missing required
fields, emit VERDICT: ERROR with REASON: Bucket/operation configuration is not valid JSON or is missing required fields — cannot plan. and REMEDIATION: Re-fetch with aws s3api get-bucket-versioning --bucket <name> --output json and re-plan.
| Bucket attribute |
Effect on operation |
Status: Enabled (versioning) |
Cleanup proceeds normally. Noncurrent versions are eligible for lifecycle rules. |
Status: Suspended |
New puts create a null-version-id object (replacing the prior null version, which becomes noncurrent). OLD versions from before suspension are still preserved. Lifecycle rules apply only to noncurrent versions created before suspension. Plan carefully — typically the operator should re-enable versioning before cleanup. |
| Versioning never enabled |
No versions exist. Nothing to clean. Emit BLOCKED with "versioning never enabled — no noncurrent versions to clean up". |
MFADelete: Enabled |
Version deletion and lifecycle rule changes require MFA. Plan for additional auth step (MFA token in CLI call). |
ObjectLockEnabled: Enabled, DefaultRetention.Mode: COMPLIANCE |
Versions within the retention window CANNOT be deleted by anyone — BLOCKED for in-retention versions. Lifecycle rules still apply to versions PAST retention. |
ObjectLockEnabled: Enabled, DefaultRetention.Mode: GOVERNANCE |
Versions can be deleted with s3:BypassGovernanceRetention permission. Lifecycle rules apply normally; Governance mode provides a softer guardrail. |
Object-level LegalHold: ON |
That specific version cannot be deleted by anyone. Lifecycle rules skip it silently. Bulk cleanup must check each object. |
| Existing lifecycle rules referencing the same prefix |
put-bucket-lifecycle-configuration REPLACES. Merge new rules into the existing config or you silently delete existing transitions. |
BucketKeyEnabled: false with SSE-KMS |
Each noncurrent version incurs a KMS GenerateDataKey charge on access. Recommend enabling Bucket Key alongside lifecycle changes. |
| Bucket in a different AWS account |
Caller needs cross-account IAM permissions on both sides. Verify before planning. |
Process — operation planning (apply in order)
Step 0: Expert knowledge — non-obvious S3 versioning behaviors
Non-obvious versioning behaviors — REPLACES-not-merges lifecycle PUT, NoncurrentVersionExpiration vs NewerNoncurrentVersions, NoncurrentDays semantics, 24-hour async rule apply, delete markers, Object Lock modes, legal holds, Storage Lens, GIR vs Flexible, Bucket Key, CRR/SRR replicas, Intelligent-Tiering — live in references/advanced-patterns.md.
Load that reference before planning configure-lifecycle or batch-delete-versions.
Step 1: Pre-check gate — BLOCKED if any check fails
Run ALL of the following pre-checks. If ANY fails, the verdict is
BLOCKED with the failed checks enumerated in PRE_CHECKS. Do NOT
execute the operation.
For ALL operations:
- Caller has
s3:GetBucketVersioning, s3:GetLifecycleConfiguration,
s3:PutLifecycleConfiguration on the bucket ARN.
- Bucket exists in the expected region and account.
- Bucket name is correct (S3 bucket names are globally unique;
verify the region matches the expectation).
For configure-lifecycle (add/modify lifecycle rules):
4. Versioning state is Enabled (or Suspended with explicit
acknowledgment — see Step 0 for behavior differences).
5. Existing lifecycle rules captured via
get-bucket-lifecycle-configuration — new rules must be MERGED
into the existing config, not REPLACE it.
6. No conflicting rules (same prefix + overlapping actions with
different NoncurrentDays values).
7. Object Lock configuration captured — Compliance-mode retention
overrides NoncurrentVersionExpiration for in-retention versions.
For batch-delete-versions (immediate cleanup via Batch Operations):
4. Versioning state is Enabled.
5. S3 Inventory configured OR a manifest generated via
list-object-versions (paginated). Batch Operations needs a
manifest of object-key + version-id pairs.
6. No Object Lock Compliance-mode versions in the manifest (delete
would fail per-object; the job continues but reports failures).
7. No legal-hold ON objects in the manifest (same per-object failure
behavior).
8. IAM role for Batch Operations has s3:DeleteObjectVersion on the
bucket AND iam:PassRole to assign the execution role.
For estimate-savings (impact audit):
4. S3 Storage Lens enabled at the account or bucket level.
5. Sample list-object-versions captured (1000 keys) to estimate
average version count and size.
Step 2: READY — emit operation plan
If all pre-checks pass, emit VERDICT: READY with the exact CLI/JSON
sequence and the CONFIRM gate. The plan includes:
- The exact AWS CLI command with the merged lifecycle JSON.
- The estimated monthly savings (computed from noncurrent version
count × average size × storage rate).
- The expected timeline (lifecycle rules apply within 24 hours of
eligibility; Batch Operations jobs run in minutes-to-hours).
- The CONFIRM gate prompt.
Step 3: Execute behind CONFIRM gate
- MANDATORY CONFIRMATION GATE. Before any state-changing CLI,
emit:
CONFIRM: About to <operation> on bucket <name> in account <account> region <region>. This will <consequence>. Estimated monthly savings: $<amount>. Proceed? (yes/no). Do NOT execute
until the operator confirms.
- Capture pre-state for audit:
aws s3api get-bucket-lifecycle-configuration --bucket <name> --output json > /tmp/<name>-lifecycle-pre-$(date +%s).json.
- Execute the CLI. For
put-bucket-lifecycle-configuration, PUT
the merged JSON (NEVER the new rules alone). For Batch Operations,
capture the JobId.
- Verify the operation:
get-bucket-lifecycle-configuration shows the new rules;
describe-job shows Batch Operations progress.
Step 4: Post-verification — COMPLETED
After the operation finishes, run post-verification. ALL checks must
pass for COMPLETED.
get-bucket-lifecycle-configuration --bucket <name> — confirm
the new rules are present AND existing rules are preserved (no
silent deletion).
- For Batch Operations:
aws s3control describe-job --account-id <acct> --job-id <id> — confirm Status: Complete,
NumberOfTasksSucceeded matches expected.
- Wait 24-48 hours, then re-check Storage Lens
NoncurrentVersionCount and NoncurrentVersionStorageBytes —
they should drop.
- Verify no compliance violations (Object Lock retention respected,
no legal-hold objects deleted).
- Verify the expected cost drop in AWS Cost Explorer (S3 service,
filtered by bucket tag or usage type) — allow 1-3 days for billing
lag.
- For lifecycle rules: verify the rule prefix filter is correct
(does not accidentally match unintended prefixes).
- Document the savings in NOTES for the operator's reporting.
If ANY verification fails, emit VERDICT: ERROR with the failure
details — do not claim COMPLETED.
Output format (per operation)
OPERATION: <configure-lifecycle | batch-delete-versions | estimate-savings | audit-versions>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <bucket-name>
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command with flags populated>
2. <wait/poll command>
3. <next step>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
ESTIMATED_SAVINGS: <$X/month (computed from N noncurrent versions × avg size × rate)>
NOTES: <compliance caveats, Object Lock implications, cleanup timeline>
Worked examples (see references/worked-examples.md)
Three full end-to-end worked examples live in
references/worked-examples.md:
- READY — configure lifecycle (3-rule cleanup). Demonstrates
NewerNoncurrentVersions=3 + NoncurrentVersionTransition to IA and
GIR, merged into 3 existing rules. ~$312/month savings.
- BLOCKED — Object Lock Compliance mode. Shows the irrevocable
retention block, enumerates the 4,287 in-retention versions, and
recommends NoncurrentVersionTransition as the only viable path.
- READY — Batch Operations immediate cleanup. 2.5M noncurrent
versions via S3 Inventory manifest; ~$2.50 Batch Operations cost;
~$825/month savings.
Each example demonstrates the exact PRE_CHECKS, STEPS with CONFIRM
gate, POST_VERIFY, and NOTES for the verdict shape.
STRICT output contract
This contract is mandatory. The Output format template above is the
authoritative structure; the rules below disambiguate the failure
modes that score D8=13 on this skill. Violating any rule produces a
plan that is unsafe to execute.
Required output structure
Every operation MUST emit this exact block, with all fields populated
(no empty fields, no omitted sections, no reordering):
OPERATION: <configure-lifecycle | batch-delete-versions | estimate-savings | audit-versions>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <bucket-name>
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command with flags populated>
2. <wait/poll command>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
ESTIMATED_SAVINGS: <$X/month (computed from N versions × avg size × rate)>
NOTES: <compliance caveats, Object Lock implications, cleanup timeline>
Verdict-specific rules:
BLOCKED → at least one PRE_CHECKS line shows [FAIL] with a
concrete reason; STEPS is (none — pre-checks failed); no
state-changing CLI is emitted.
READY → all PRE_CHECKS show [PASS]; STEPS begins with the
CONFIRM gate prompt before any state-changing CLI; POST_VERIFY is
(pending execution); ESTIMATED_SAVINGS cites the storage math.
COMPLETED → all POST_VERIFY show [PASS]; STEPS reflects what
was actually executed; ESTIMATED_SAVINGS is the realised (not
estimated) savings if measurable.
FORBIDDEN output patterns
- NEVER recommend NoncurrentVersionExpiration without checking Object
Lock — Compliance mode makes versions immutable regardless of
lifecycle rules. A READY plan that did not run
get-object-lock-configuration and confirm the mode is invalid.
- NEVER suggest put-bucket-lifecycle-configuration as a merge — it
REPLACES the entire configuration. Always read-merge-write: call
get-bucket-lifecycle-configuration, merge the new rules into the
existing JSON, then PUT the merged payload. A STEPS entry that PUTs
only the new rules is a data-loss bug.
- NEVER conflate
Expiration (current version) with
NoncurrentVersionExpiration (noncurrent versions). Expiration
creates a delete marker on versioned buckets; it does NOT remove
old versions. A STEPS entry using the wrong action cleans up
nothing.
- NEVER emit
VERDICT: READY without the CONFIRM gate as the first
STEPS item. State-changing CLIs (lifecycle PUT, delete-objects,
create-job) require explicit operator approval before execution;
emitting the CLI without the CONFIRM prompt is a violation.
- NEVER attempt to delete objects with
LegalHold: ON. Legal hold
overrides all lifecycle and Object Lock settings. A batch-delete
plan that did not sample get-object-legal-hold is incomplete —
per-object failures will occur silently mid-job.
- NEVER output
VERDICT: BLOCKED without enumerating each failed
PRE_CHECK with a [FAIL] line and a reason. A bare "BLOCKED —
pre-checks failed" with no itemised failures is not actionable.
- NEVER assume lifecycle rules apply in real time. S3 processes
rules asynchronously within 24 hours of eligibility. A COMPLETED
verdict that claims immediate cost reduction without the 24-48h
verification window is misleading.
Perfect example output
OPERATION: configure-lifecycle
VERDICT: READY
TARGET: s3://prod-logs-bucket
PRE_CHECKS:
- [PASS] Bucket exists in us-east-1 account 111111111111
- [PASS] Versioning Status: Enabled
- [PASS] MFADelete: Disabled (no MFA required)
- [PASS] ObjectLockEnabled: Disabled (no Compliance/Governance
retention — NoncurrentVersionExpiration is safe)
- [PASS] Existing lifecycle rules captured (3 rules: current-version
transition, current-version expiration on logs/ prefix,
abort-multipart-upload 7d) via get-bucket-lifecycle-configuration
- [PASS] New rules MERGED into existing config (not replacing) —
PUT payload contains all 5 rules
- [PASS] BucketKeyEnabled: true (no KMS optimization gap)
- [PASS] Caller has s3:PutLifecycleConfiguration
STEPS:
1. CONFIRM: About to put-bucket-lifecycle-configuration on
s3://prod-logs-bucket in account 111111111111 region us-east-1.
This will ADD NoncurrentVersionExpiration (NoncurrentDays: 90)
and NoncurrentVersionTransition (STANDARD_IA at 30d, GIR at 90d)
to the existing 3 rules. Existing rules preserved in the merged
payload. Estimated monthly savings: $312/month. Proceed? (yes/no)
2. aws s3api put-bucket-lifecycle-configuration \
--bucket prod-logs-bucket \
--lifecycle-configuration file:///tmp/prod-logs-bucket-merged-lifecycle.json
3. aws s3api get-bucket-lifecycle-configuration \
--bucket prod-logs-bucket --output json
POST_VERIFY:
- (pending execution)
ESTIMATED_SAVINGS: $312/month (13.5 TB noncurrent × $0.023/GB-month;
after transition to IA + GIR: $95/month; net savings $217/month)
NOTES:
- Lifecycle rules apply within 24 hours of eligibility. Allow 24-48
hours for the first noncurrent versions to transition/expire.
- The existing 3 rules are PRESERVED in the merged config — verified
by reading the post-PUT lifecycle configuration in Step 3.
- For immediate cleanup of versions already older than 90d, use S3
Batch Operations (separate operation).
Anti-Patterns — NEVER (top 5)
NEVER execute put-bucket-lifecycle-configuration without first
reading existing rules. The PUT REPLACES the entire configuration
— silently deleting existing transitions and expirations is the #1
S3 lifecycle mistake. Always read-merge-write.
NEVER attempt to delete versions in an Object Lock Compliance-mode
bucket within the retention window. NO ONE — including root,
including AWS support — can delete them. Apply lifecycle transitions
instead; versions past retention will transition.
NEVER attempt to delete objects with LegalHold: ON or conflate
Expiration with NoncurrentVersionExpiration. Legal hold
overrides all settings (check via get-object-legal-hold).
Expiration creates a delete marker on versioned buckets; it does
NOT remove old versions — use NoncurrentVersionExpiration.
NEVER auto-execute a state-changing S3 CLI without the CONFIRM
gate, and NEVER skip the post-PUT lifecycle verification. Lifecycle
PUTs and Batch Operations jobs have side effects; a malformed JSON
can be silently rejected. Always emit CONFIRM, wait, then re-read.
NEVER recommend S3 Batch Operations without estimating the
per-million-object cost (~$1.00/million) and never use
list-object-versions as the manifest source for large buckets.
Use S3 Inventory for buckets with millions of versions; paginating
list-object-versions is too slow and consumes API quota.
Additional NEVER rules (MFADelete check, compliance retention
verification, GIR vs Flexible latency, CRR/SRR replica lifecycle,
Intelligent-Tiering monitoring fee, Bucket Key, delete-objects with
version IDs, cross-account IAM) appear in the FORBIDDEN output
patterns section above and in references/lifecycle-rule-patterns.md.
Pre-flight safety checks (run before any remediation CLI)
The full pre-flight safety checklist — confirm gate, pre-state capture, versioning/Object Lock/legal-hold verification, read-merge-write lifecycle, cleanup timeline, prefix verification — lives in references/diagnostic-commands.md.
Run these before any remediation CLI.
Recent AWS features (2024-2026)
Recent AWS features 2024-2026 — Intelligent-Tiering 90-day archive default, GIR lifecycle GA, S3DeleteObjectVersion in Batch Operations, Governance bypass logging, Storage Lens dimensions, Bucket Key defaults, lifecycle conflict warnings — live in references/advanced-patterns.md.
Load when planning rules on buckets that use these features.
References (load on demand)
- references/worked-examples.md — full end-to-end worked examples (READY lifecycle, BLOCKED Object Lock, READY Batch Operations)
- references/lifecycle-rule-patterns.md — lifecycle JSON anatomy, expiration-vs-keep heuristic, Batch Operations cost table
- references/advanced-patterns.md — Step-0 non-obvious versioning behaviors and recent AWS features (2024-2026)
- references/diagnostic-commands.md — pre-flight safety checks and pre-state capture commands
Domain
AWS CloudOps / S3 Storage Cost Optimization & Compliance Retention.
Expert heuristic and Batch Operations cost (see references/lifecycle-rule-patterns.md)
The full NoncurrentVersionExpiration-vs-NewerNoncurrentVersions
heuristic (with defense-in-depth JSON example and common-mistake
analysis) and the S3 Batch Operations per-million-object cost
comparison table (with payback-period maths and decision rule) live
in references/lifecycle-rule-patterns.md.
AWS documentation
1---2name: s3-version-cleanup-operator3description: Operates S3 version cleanup for cost optimization and compliance — NoncurrentVersionExpiration, NoncurrentVersionTransition, NewerNoncurrentVersions, AbortIncompleteMultipartUpload lifecycle rules, S3 Batch Operations for immediate version delete, Object Lock (Compliance vs Governance mode) and legal-hold handling, versioning-state pre-checks (Enabled vs Suspended), Storage Lens impact estimation, and post-apply verification. Runs deterministic pre-checks (versioning enabled, Object Lock mode and retention, legal holds, existing lifecycle rule conflicts, BucketKeyEnabled for cost), executes the operation behind a CONFIRM gate, and emits a verdict (READY | BLOCKED | COMPLETED) per bucket with the exact CLI/JSON sequence, estimated monthly savings, and verification commands. Use when auditing noncurrent version accumulation, configuring version cleanup lifecycle rules, planning immediate cleanup via Batch Operations, handling Object Lock retention, or estimating S3 version cleanup savings.4license: Apache-2.05compatibility: 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 s3api get-bucket-versioning, put-bucket-versioning, get-bucket-lifecycle-configuration, put-bucket-lifecycle-configuration, get-object-lock-configuration, get-object-legal-hold, list-object-versions, delete-objects, and aws s3control create-job (S3 Batch Operations) (AWS CLI v2, SSO or key-based credentials).6metadata:7 source: https://skillmd.com/skills/jhkchan/s3-version-cleanup-operator8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '4'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Storage15 task_type: operate16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY | BLOCKED | COMPLETED19 version: 0.1.020 author: Jacky Chan — AWS Community Builder21 tags: s3, storage, versioning, lifecycle, cost-optimization, object-lock, batch-operations22 dependencies: aws-orchestrator23 keywords: S3, versioning, noncurrent versions, NoncurrentVersionExpiration, NoncurrentVersionTransition, NewerNoncurrentVersions, lifecycle rule, AbortIncompleteMultipartUpload, S3 Batch Operations, Object Lock, Compliance mode, Governance mode, legal hold, S3 Storage Lens, cost optimization, version cleanup, delete markers, BucketKeyEnabled24 when_to_use: Auditing S3 noncurrent version accumulation, configuring version cleanup lifecycle rules (NoncurrentVersionExpiration, NoncurrentVersionTransition, NewerNoncurrentVersions), planning immediate version cleanup via S3 Batch Operations, handling Object Lock retention before cleanup, estimating S3 version cleanup savings, or hardening S3 cost posture on versioned buckets.25 activation_triggers: clean up S3 versions, S3 noncurrent versions cost, configure S3 lifecycle NoncurrentVersionExpiration, S3 version cleanup, S3 Object Lock retention, S3 legal hold, S3 Batch Operations delete versions, S3 cost optimization versions, S3 Storage Lens noncurrent, abort multipart upload S3, S3 NewerNoncurrentVersions, versioned bucket cleanup, S3 lifecycle configuration26 invocation_schema: 'Input: either (a) a bucket configuration with the intended operation (configure-lifecycle, batch-delete-versions, audit- versions, estimate-savings), OR (b) a bucket name + operation for live-account execution. Output: deterministic OPERATION/VERDICT/ PRE_CHECKS/STEPS/POST_VERIFY block per operation, where VERDICT is one of READY, BLOCKED, COMPLETED.'27---2829# S3 Version Cleanup Operator3031## What this skill does3233Executes S3 version cleanup operations correctly and safely — for34cost optimization and for compliance retention. Runs deterministic35pre-checks before any state-changing CLI (versioning state, Object36Lock mode + retention, legal holds, existing lifecycle conflicts),37executes the operation behind a CONFIRM gate, and verifies the38result. Every operation surfaces the estimated monthly savings, the39compliance implications, and the verification steps.4041## Quick navigation4243| Section | What it covers | When to read it |44|---|---|---|45| **§ Quick reference** | Verdict thresholds (BLOCKED/READY/COMPLETED) + pre-check priority order | Before any operation |46| **§ Mindset** | Why version cleanup is the #1 S3 cost lever, the 4 lifecycle rule types, Object Lock modes | Understanding the cost model |47| **§ Pre-flight** | Bucket metadata gate — versioning state, Object Lock, legal holds, existing lifecycle | Before executing any CLI |48| **§ Process** | Per-operation planning: lifecycle rules, batch-delete, impact estimation, audit | When choosing which operation to run |49| **§ Output format** | Structured output template with VERDICT, COMMANDS, SAVINGS, VERIFICATION | Formatting the response |50| **§ Anti-Patterns** | NEVER list — common mistakes that cause data loss or compliance violation | Review before risky operations |51| **§ Pre-flight safety** | Additional checks before any remediation CLI | Defense-in-depth |5253## Quick reference — verdict thresholds5455| Verdict | Trigger condition | Action |56|---|---|---|57| `BLOCKED` | One or more pre-checks failed (versioning not enabled, Object Lock Compliance mode blocks deletion, legal hold active, lifecycle rule conflict, bucket in a different region/account than expected) | List failures, do NOT execute |58| `READY` | All pre-checks passed; awaiting CONFIRM gate | Emit exact CLI/JSON sequence, wait for operator yes |59| `COMPLETED` | Operation finished and post-verification passed (lifecycle rule applied, Batch Operations job completed, noncurrent version count dropped) | Emit savings estimate, verification results |6061**Priority order for pre-checks (apply in this sequence, all must pass62for READY):**63641. **Versioning state** — must be `Enabled` for cleanup to affect65 noncurrent versions. `Suspended` is a different state (new puts66 create a null-version-id object, old versions are preserved).67 `NeverEnabled` → no versions exist, nothing to clean.682. **Object Lock** — if `Compliance` mode is active with retention,69 versions CANNOT be deleted or overwritten until retention expires70 (not even by root). `Governance` mode permits deletion with71 `s3:BypassGovernanceRetention` permission.723. **Legal holds** — per-object `LegalHold: ON` prevents deletion73 regardless of lifecycle, Object Lock mode, or retention. Check74 via `get-object-legal-hold` for specific objects.754. **Existing lifecycle rules** — `put-bucket-lifecycle-configuration`76 **REPLACES** the entire configuration, not merges. Read existing77 rules first and merge new rules; otherwise you silently delete78 existing transitions/expirations.795. **MFA Delete** — if `MFADelete: Enabled` on the bucket, version80 deletion and lifecycle rule changes require MFA. Plan for the81 additional auth step.826. **Bucket Key** — `BucketKeyEnabled: true` reduces KMS request cost83 on encrypted buckets (~99% reduction). Recommend enabling alongside84 lifecycle changes.8586**Cost/savings baselines (2026 us-east-1):**8788- Standard storage: ~$0.023/GB-month.89- Standard-IA: ~$0.0125/GB-month (50% cheaper, but 30-day minimum +90 retrieval fee).91- Glacier Instant Retrieval: ~$0.004/GB-month (~83% cheaper).92- Glacier Flexible Retrieval: ~$0.0036/GB-month (~84% cheaper).93- Glacier Deep Archive: ~$0.00099/GB-month (~96% cheaper).94- One-time delete via lifecycle or Batch Operations: free (no per-delete95 charge).96- S3 Batch Operations: ~$1.00 per million objects processed.9798**Rule of thumb:** versioned buckets with frequent overwrites99accumulate noncurrent versions at the same rate as the overwrite100frequency × object size. A 1 GB log file overwritten hourly = 24101noncurrent versions/day × $0.023/GB ≈ $0.55/month — scales linearly102with overwrite count.103104## Mindset105106**One-line takeaway:** versioned buckets accumulate noncurrent versions107indefinitely at standard storage rates — version cleanup is the #1 S3108cost optimization after storage-class transitions. Driven by four109realities:110111- **Every noncurrent version bills at full Standard rate by default.**112 Unlike S3 IA or Glacier, noncurrent versions are NOT automatically113 tiered. A 1 GB file overwritten 100 times is 100 GB of Standard114 storage — 100x the cost of the current version alone.115- **Object Lock Compliance mode is irrevocable.** If Compliance mode is116 active with retention until 2030, no one (including root, including117 AWS support) can delete those versions before 2030. This is the118 correct posture for ransomware-resilient backups — and a hard block119 for version cleanup.120- **`put-bucket-lifecycle-configuration` REPLACES, not merges.** Every121 operator who forgets this silently deletes the existing lifecycle122 rules — transitions, expirations, abort-multipart rules — and the123 bucket reverts to "no lifecycle" until the operator notices (usually124 via a cost spike months later).125- **Legal holds override everything.** A single `LegalHold: ON` on one126 object blocks its deletion regardless of Object Lock mode, retention,127 lifecycle rules, or root access. Legal holds are per-object; bulk128 cleanup requires checking each object (or using Batch Operations with129 a manifest).130131## Pre-flight: bucket metadata gate132133Run before classification. Misclassifying these produces wrong plans.134135**Pagination:** `list-object-versions` paginates at 1000 keys/page —136drain `--key-marker` and `--version-id-marker` to completion. Use S3137Storage Lens for account-wide noncurrent version metrics instead of138enumerating every bucket.139140**Live-account pre-flight (skip if offline plan audit):**1411. `aws s3api get-bucket-versioning --bucket <name>` — confirm142 `Status: Enabled`. Capture `MFADelete` (if enabled, plan for MFA).1432. `aws s3api get-bucket-lifecycle-configuration --bucket <name>` —144 capture existing rules. NEVER overwrite without first reading.1453. `aws s3api get-object-lock-configuration --bucket <name>` — capture146 `ObjectLockEnabled` and `Rule.DefaultRetention` (Mode, Days, Years).1474. `aws s3api get-public-access-block --bucket <name>` — context only.1485. `aws s3api get-bucket-encryption --bucket <name>` — capture149 `BucketKeyEnabled` (recommend enabling if false and SSE-KMS in use).1506. `aws s3api list-object-versions --bucket <name --max-keys 1000` —151 sample the noncurrent version count and average size for impact152 estimation.1537. `aws s3control get-storage-lens-configuration --config-id default`154 — capture account-level `NoncurrentVersionCount` and155 `NoncurrentVersionStorageBytes`.1568. For specific objects being cleaned: `aws s3api get-object-legal-hold157 --bucket <name> --key <key> --version-id <vid>` — verify no legal158 hold before batch-delete.159160**Malformed input:** if the input JSON is invalid or missing required161fields, emit `VERDICT: ERROR` with `REASON: Bucket/operation162configuration is not valid JSON or is missing required fields — cannot163plan.` and `REMEDIATION: Re-fetch with aws s3api get-bucket-versioning164--bucket <name> --output json and re-plan.`165166| Bucket attribute | Effect on operation |167|---|---|168| `Status: Enabled` (versioning) | Cleanup proceeds normally. Noncurrent versions are eligible for lifecycle rules. |169| `Status: Suspended` | New puts create a null-version-id object (replacing the prior null version, which becomes noncurrent). OLD versions from before suspension are still preserved. Lifecycle rules apply only to noncurrent versions created before suspension. Plan carefully — typically the operator should re-enable versioning before cleanup. |170| Versioning never enabled | No versions exist. Nothing to clean. Emit BLOCKED with "versioning never enabled — no noncurrent versions to clean up". |171| `MFADelete: Enabled` | Version deletion and lifecycle rule changes require MFA. Plan for additional auth step (MFA token in CLI call). |172| `ObjectLockEnabled: Enabled`, `DefaultRetention.Mode: COMPLIANCE` | Versions within the retention window CANNOT be deleted by anyone — BLOCKED for in-retention versions. Lifecycle rules still apply to versions PAST retention. |173| `ObjectLockEnabled: Enabled`, `DefaultRetention.Mode: GOVERNANCE` | Versions can be deleted with `s3:BypassGovernanceRetention` permission. Lifecycle rules apply normally; Governance mode provides a softer guardrail. |174| Object-level `LegalHold: ON` | That specific version cannot be deleted by anyone. Lifecycle rules skip it silently. Bulk cleanup must check each object. |175| Existing lifecycle rules referencing the same prefix | `put-bucket-lifecycle-configuration` REPLACES. Merge new rules into the existing config or you silently delete existing transitions. |176| `BucketKeyEnabled: false` with SSE-KMS | Each noncurrent version incurs a KMS `GenerateDataKey` charge on access. Recommend enabling Bucket Key alongside lifecycle changes. |177| Bucket in a different AWS account | Caller needs cross-account IAM permissions on both sides. Verify before planning. |178179## Process — operation planning (apply in order)180181### Step 0: Expert knowledge — non-obvious S3 versioning behaviors182183Non-obvious versioning behaviors — REPLACES-not-merges lifecycle PUT, NoncurrentVersionExpiration vs NewerNoncurrentVersions, NoncurrentDays semantics, 24-hour async rule apply, delete markers, Object Lock modes, legal holds, Storage Lens, GIR vs Flexible, Bucket Key, CRR/SRR replicas, Intelligent-Tiering — live in [references/advanced-patterns.md](references/advanced-patterns.md).184Load that reference before planning configure-lifecycle or batch-delete-versions.185186### Step 1: Pre-check gate — BLOCKED if any check fails187188Run ALL of the following pre-checks. If ANY fails, the verdict is189BLOCKED with the failed checks enumerated in PRE_CHECKS. Do NOT190execute the operation.191192**For ALL operations:**1931. Caller has `s3:GetBucketVersioning`, `s3:GetLifecycleConfiguration`,194 `s3:PutLifecycleConfiguration` on the bucket ARN.1952. Bucket exists in the expected region and account.1963. Bucket name is correct (S3 bucket names are globally unique;197 verify the region matches the expectation).198199**For configure-lifecycle (add/modify lifecycle rules):**2004. Versioning state is `Enabled` (or `Suspended` with explicit201 acknowledgment — see Step 0 for behavior differences).2025. Existing lifecycle rules captured via203 `get-bucket-lifecycle-configuration` — new rules must be MERGED204 into the existing config, not REPLACE it.2056. No conflicting rules (same prefix + overlapping actions with206 different NoncurrentDays values).2077. Object Lock configuration captured — Compliance-mode retention208 overrides NoncurrentVersionExpiration for in-retention versions.209210**For batch-delete-versions (immediate cleanup via Batch Operations):**2114. Versioning state is `Enabled`.2125. S3 Inventory configured OR a manifest generated via213 `list-object-versions` (paginated). Batch Operations needs a214 manifest of object-key + version-id pairs.2156. No Object Lock Compliance-mode versions in the manifest (delete216 would fail per-object; the job continues but reports failures).2177. No legal-hold ON objects in the manifest (same per-object failure218 behavior).2198. IAM role for Batch Operations has `s3:DeleteObjectVersion` on the220 bucket AND `iam:PassRole` to assign the execution role.221222**For estimate-savings (impact audit):**2234. S3 Storage Lens enabled at the account or bucket level.2245. Sample `list-object-versions` captured (1000 keys) to estimate225 average version count and size.226227### Step 2: READY — emit operation plan228229If all pre-checks pass, emit `VERDICT: READY` with the exact CLI/JSON230sequence and the CONFIRM gate. The plan includes:231232- The exact AWS CLI command with the merged lifecycle JSON.233- The estimated monthly savings (computed from noncurrent version234 count × average size × storage rate).235- The expected timeline (lifecycle rules apply within 24 hours of236 eligibility; Batch Operations jobs run in minutes-to-hours).237- The CONFIRM gate prompt.238239### Step 3: Execute behind CONFIRM gate240241- **MANDATORY CONFIRMATION GATE.** Before any state-changing CLI,242 emit: `CONFIRM: About to <operation> on bucket <name> in account243 <account> region <region>. This will <consequence>. Estimated244 monthly savings: $<amount>. Proceed? (yes/no)`. Do NOT execute245 until the operator confirms.246- Capture pre-state for audit:247 `aws s3api get-bucket-lifecycle-configuration --bucket <name>248 --output json > /tmp/<name>-lifecycle-pre-$(date +%s).json`.249- Execute the CLI. For `put-bucket-lifecycle-configuration`, PUT250 the merged JSON (NEVER the new rules alone). For Batch Operations,251 capture the JobId.252- Verify the operation:253 `get-bucket-lifecycle-configuration` shows the new rules;254 `describe-job` shows Batch Operations progress.255256### Step 4: Post-verification — COMPLETED257258After the operation finishes, run post-verification. ALL checks must259pass for `COMPLETED`.2602611. `get-bucket-lifecycle-configuration --bucket <name>` — confirm262 the new rules are present AND existing rules are preserved (no263 silent deletion).2642. For Batch Operations: `aws s3control describe-job --account-id265 <acct> --job-id <id>` — confirm `Status: Complete`,266 `NumberOfTasksSucceeded` matches expected.2673. Wait 24-48 hours, then re-check Storage Lens268 `NoncurrentVersionCount` and `NoncurrentVersionStorageBytes` —269 they should drop.2704. Verify no compliance violations (Object Lock retention respected,271 no legal-hold objects deleted).2725. Verify the expected cost drop in AWS Cost Explorer (S3 service,273 filtered by bucket tag or usage type) — allow 1-3 days for billing274 lag.2756. For lifecycle rules: verify the rule prefix filter is correct276 (does not accidentally match unintended prefixes).2777. Document the savings in NOTES for the operator's reporting.278279If ANY verification fails, emit `VERDICT: ERROR` with the failure280details — do not claim COMPLETED.281282## Output format (per operation)283284```text285OPERATION: <configure-lifecycle | batch-delete-versions | estimate-savings | audit-versions>286VERDICT: READY | BLOCKED | COMPLETED287TARGET: <bucket-name>288PRE_CHECKS:289 - [PASS] <check description>290 - [FAIL] <check description> — <reason>291STEPS:292 1. <CLI command with flags populated>293 2. <wait/poll command>294 3. <next step>295POST_VERIFY:296 - [PASS] <verification description>297 - [FAIL] <verification description> — <reason>298ESTIMATED_SAVINGS: <$X/month (computed from N noncurrent versions × avg size × rate)>299NOTES: <compliance caveats, Object Lock implications, cleanup timeline>300```301302### Worked examples (see references/worked-examples.md)303304Three full end-to-end worked examples live in305`references/worked-examples.md`:306307- **READY — configure lifecycle (3-rule cleanup).** Demonstrates308 NewerNoncurrentVersions=3 + NoncurrentVersionTransition to IA and309 GIR, merged into 3 existing rules. ~$312/month savings.310- **BLOCKED — Object Lock Compliance mode.** Shows the irrevocable311 retention block, enumerates the 4,287 in-retention versions, and312 recommends NoncurrentVersionTransition as the only viable path.313- **READY — Batch Operations immediate cleanup.** 2.5M noncurrent314 versions via S3 Inventory manifest; ~$2.50 Batch Operations cost;315 ~$825/month savings.316317Each example demonstrates the exact PRE_CHECKS, STEPS with CONFIRM318gate, POST_VERIFY, and NOTES for the verdict shape.319320## STRICT output contract321322This contract is mandatory. The Output format template above is the323authoritative structure; the rules below disambiguate the failure324modes that score D8=13 on this skill. Violating any rule produces a325plan that is unsafe to execute.326327### Required output structure328329Every operation MUST emit this exact block, with all fields populated330(no empty fields, no omitted sections, no reordering):331332```text333OPERATION: <configure-lifecycle | batch-delete-versions | estimate-savings | audit-versions>334VERDICT: READY | BLOCKED | COMPLETED335TARGET: <bucket-name>336PRE_CHECKS:337 - [PASS] <check description>338 - [FAIL] <check description> — <reason>339STEPS:340 1. <CLI command with flags populated>341 2. <wait/poll command>342POST_VERIFY:343 - [PASS] <verification description>344 - [FAIL] <verification description> — <reason>345ESTIMATED_SAVINGS: <$X/month (computed from N versions × avg size × rate)>346NOTES: <compliance caveats, Object Lock implications, cleanup timeline>347```348349Verdict-specific rules:350- `BLOCKED` → at least one PRE_CHECKS line shows `[FAIL]` with a351 concrete reason; STEPS is `(none — pre-checks failed)`; no352 state-changing CLI is emitted.353- `READY` → all PRE_CHECKS show `[PASS]`; STEPS begins with the354 CONFIRM gate prompt before any state-changing CLI; POST_VERIFY is355 `(pending execution)`; ESTIMATED_SAVINGS cites the storage math.356- `COMPLETED` → all POST_VERIFY show `[PASS]`; STEPS reflects what357 was actually executed; ESTIMATED_SAVINGS is the realised (not358 estimated) savings if measurable.359360### FORBIDDEN output patterns3613621. NEVER recommend NoncurrentVersionExpiration without checking Object363 Lock — Compliance mode makes versions immutable regardless of364 lifecycle rules. A READY plan that did not run365 `get-object-lock-configuration` and confirm the mode is invalid.3662. NEVER suggest put-bucket-lifecycle-configuration as a merge — it367 REPLACES the entire configuration. Always read-merge-write: call368 `get-bucket-lifecycle-configuration`, merge the new rules into the369 existing JSON, then PUT the merged payload. A STEPS entry that PUTs370 only the new rules is a data-loss bug.3713. NEVER conflate `Expiration` (current version) with372 `NoncurrentVersionExpiration` (noncurrent versions). `Expiration`373 creates a delete marker on versioned buckets; it does NOT remove374 old versions. A STEPS entry using the wrong action cleans up375 nothing.3764. NEVER emit `VERDICT: READY` without the CONFIRM gate as the first377 STEPS item. State-changing CLIs (lifecycle PUT, `delete-objects`,378 `create-job`) require explicit operator approval before execution;379 emitting the CLI without the CONFIRM prompt is a violation.3805. NEVER attempt to delete objects with `LegalHold: ON`. Legal hold381 overrides all lifecycle and Object Lock settings. A batch-delete382 plan that did not sample `get-object-legal-hold` is incomplete —383 per-object failures will occur silently mid-job.3846. NEVER output `VERDICT: BLOCKED` without enumerating each failed385 PRE_CHECK with a `[FAIL]` line and a reason. A bare "BLOCKED —386 pre-checks failed" with no itemised failures is not actionable.3877. NEVER assume lifecycle rules apply in real time. S3 processes388 rules asynchronously within 24 hours of eligibility. A COMPLETED389 verdict that claims immediate cost reduction without the 24-48h390 verification window is misleading.391392### Perfect example output393394```text395OPERATION: configure-lifecycle396VERDICT: READY397TARGET: s3://prod-logs-bucket398PRE_CHECKS:399 - [PASS] Bucket exists in us-east-1 account 111111111111400 - [PASS] Versioning Status: Enabled401 - [PASS] MFADelete: Disabled (no MFA required)402 - [PASS] ObjectLockEnabled: Disabled (no Compliance/Governance403 retention — NoncurrentVersionExpiration is safe)404 - [PASS] Existing lifecycle rules captured (3 rules: current-version405 transition, current-version expiration on logs/ prefix,406 abort-multipart-upload 7d) via get-bucket-lifecycle-configuration407 - [PASS] New rules MERGED into existing config (not replacing) —408 PUT payload contains all 5 rules409 - [PASS] BucketKeyEnabled: true (no KMS optimization gap)410 - [PASS] Caller has s3:PutLifecycleConfiguration411STEPS:412 1. CONFIRM: About to put-bucket-lifecycle-configuration on413 s3://prod-logs-bucket in account 111111111111 region us-east-1.414 This will ADD NoncurrentVersionExpiration (NoncurrentDays: 90)415 and NoncurrentVersionTransition (STANDARD_IA at 30d, GIR at 90d)416 to the existing 3 rules. Existing rules preserved in the merged417 payload. Estimated monthly savings: $312/month. Proceed? (yes/no)418 2. aws s3api put-bucket-lifecycle-configuration \419 --bucket prod-logs-bucket \420 --lifecycle-configuration file:///tmp/prod-logs-bucket-merged-lifecycle.json421 3. aws s3api get-bucket-lifecycle-configuration \422 --bucket prod-logs-bucket --output json423POST_VERIFY:424 - (pending execution)425ESTIMATED_SAVINGS: $312/month (13.5 TB noncurrent × $0.023/GB-month;426 after transition to IA + GIR: $95/month; net savings $217/month)427NOTES:428 - Lifecycle rules apply within 24 hours of eligibility. Allow 24-48429 hours for the first noncurrent versions to transition/expire.430 - The existing 3 rules are PRESERVED in the merged config — verified431 by reading the post-PUT lifecycle configuration in Step 3.432 - For immediate cleanup of versions already older than 90d, use S3433 Batch Operations (separate operation).434```435436## Anti-Patterns — NEVER (top 5)4374381. **NEVER execute `put-bucket-lifecycle-configuration` without first439 reading existing rules.** The PUT REPLACES the entire configuration440 — silently deleting existing transitions and expirations is the #1441 S3 lifecycle mistake. Always read-merge-write.4424432. **NEVER attempt to delete versions in an Object Lock Compliance-mode444 bucket within the retention window.** NO ONE — including root,445 including AWS support — can delete them. Apply lifecycle transitions446 instead; versions past retention will transition.4474483. **NEVER attempt to delete objects with `LegalHold: ON` or conflate449 `Expiration` with `NoncurrentVersionExpiration`.** Legal hold450 overrides all settings (check via `get-object-legal-hold`). 451 `Expiration` creates a delete marker on versioned buckets; it does452 NOT remove old versions — use `NoncurrentVersionExpiration`.4534544. **NEVER auto-execute a state-changing S3 CLI without the CONFIRM455 gate, and NEVER skip the post-PUT lifecycle verification.** Lifecycle456 PUTs and Batch Operations jobs have side effects; a malformed JSON457 can be silently rejected. Always emit CONFIRM, wait, then re-read.4584595. **NEVER recommend S3 Batch Operations without estimating the460 per-million-object cost (~$1.00/million) and never use461 `list-object-versions` as the manifest source for large buckets.**462 Use S3 Inventory for buckets with millions of versions; paginating463 `list-object-versions` is too slow and consumes API quota.464465Additional NEVER rules (MFADelete check, compliance retention466verification, GIR vs Flexible latency, CRR/SRR replica lifecycle,467Intelligent-Tiering monitoring fee, Bucket Key, `delete-objects` with468version IDs, cross-account IAM) appear in the FORBIDDEN output469patterns section above and in `references/lifecycle-rule-patterns.md`.470471## Pre-flight safety checks (run before any remediation CLI)472473The full pre-flight safety checklist — confirm gate, pre-state capture, versioning/Object Lock/legal-hold verification, read-merge-write lifecycle, cleanup timeline, prefix verification — lives in [references/diagnostic-commands.md](references/diagnostic-commands.md).474Run these before any remediation CLI.475476## Recent AWS features (2024-2026)477478Recent AWS features 2024-2026 — Intelligent-Tiering 90-day archive default, GIR lifecycle GA, S3DeleteObjectVersion in Batch Operations, Governance bypass logging, Storage Lens dimensions, Bucket Key defaults, lifecycle conflict warnings — live in [references/advanced-patterns.md](references/advanced-patterns.md).479Load when planning rules on buckets that use these features.480481## References (load on demand)482483- [references/worked-examples.md](references/worked-examples.md) — full end-to-end worked examples (READY lifecycle, BLOCKED Object Lock, READY Batch Operations)484- [references/lifecycle-rule-patterns.md](references/lifecycle-rule-patterns.md) — lifecycle JSON anatomy, expiration-vs-keep heuristic, Batch Operations cost table485- [references/advanced-patterns.md](references/advanced-patterns.md) — Step-0 non-obvious versioning behaviors and recent AWS features (2024-2026)486- [references/diagnostic-commands.md](references/diagnostic-commands.md) — pre-flight safety checks and pre-state capture commands487488## Domain489490AWS CloudOps / S3 Storage Cost Optimization & Compliance Retention.491492## Expert heuristic and Batch Operations cost (see references/lifecycle-rule-patterns.md)493494The full NoncurrentVersionExpiration-vs-NewerNoncurrentVersions495heuristic (with defense-in-depth JSON example and common-mistake496analysis) and the S3 Batch Operations per-million-object cost497comparison table (with payback-period maths and decision rule) live498in `references/lifecycle-rule-patterns.md`.499500## AWS documentation501502- **Amazon S3 User Guide** — https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html503- **S3 Versioning** — https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html504- **S3 Lifecycle configuration** — https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html505- **S3 Object Lock** — https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html506- **S3 Batch Operations** — https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-operations.html507- **S3 Storage Lens** — https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage_lens.html508- **AWS CLI s3api reference** — https://docs.aws.amazon.com/cli/latest/reference/s3api/509- **Bucket Key** — https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key.html