What actually makes up an S3 bill for an API workload?

An S3 bill has five main components. Each scales with a different property of your workload, so a lifecycle rule that reduces one can increase another.

Cost component What it scales with Why it matters for APIs
Storage GB-months stored, per class Small when objects are a few KB each
Requests (PUT, GET, LIST) Number of operations Every API write and read is billed
Lifecycle transitions Number of objects moved Charged per object, regardless of size
Retrieval GB read from infrequent-access classes Penalises reading "cold" data
Data transfer GB leaving the region or going to the internet Often larger than storage for public assets

Many API workloads store large numbers of small objects, such as JSON request payloads, webhook bodies and thumbnails. For these, stored bytes are rarely the expensive part. As an illustrative estimate, ten million 4 KB objects add up to roughly 40 GB. That is a modest storage line, but it means ten million PUTs to create the objects and ten million transition requests if a rule moves them all.

Cheaper storage classes add two more conditions that work against small objects. Standard-IA bills each object as at least 128 KB, and it charges for a minimum storage duration even if you delete the object earlier. A 4 KB object moved to Standard-IA can therefore cost more than it did in Standard.

Lifecycle rules exist to match each object's storage class and lifetime to how it is used. Whether they save money depends almost entirely on one thing: how often an object is read after it is written. That read pattern is what the rest of this article measures before any rule is written.

Who should use S3 lifecycle rules?

Lifecycle rules are worth the effort for teams whose API stores data in S3 that keeps growing and loses value with age. Typical cases:

  • API backends that write logs, request archives or audit trails to S3 and rarely read them after the first days or weeks.
  • Services that generate exports, reports or renditions that users download soon after creation and seldom afterwards.
  • Upload pipelines with scratch or raw data, where the original is processed once and then only kept "just in case", or not needed at all.
  • Versioned buckets with frequent overwrites, where noncurrent versions pile up unnoticed.
  • Any bucket accumulating incomplete multipart uploads from clients that fail mid-upload.

They are a poor fit, or at least a low priority, for:

  • Buckets that hold only a few gigabytes, where the engineering time outweighs any saving.
  • Workloads dominated by small objects that are read often, where staying in Standard is usually cheapest.
  • Data whose read pattern you have not measured yet. Profile first, then write rules.

The people who should own the rules are the engineers who own the key layout and the data's retention requirements, not only whoever manages the bill. A rule encodes a product decision about how long data is kept and how quickly it must be readable.

How do S3 storage classes differ on the properties that drive cost?

Each class trades a lower per-GB storage rate for some combination of retrieval fees, billing floors, or slower access. Those terms, not the storage rate alone, decide whether a move saves money.

Class First-byte latency Read path Per-GB retrieval fee Minimum storage duration Minimum billable size
Standard Milliseconds Synchronous GET No None None
Standard-IA Milliseconds Synchronous GET Yes 30 days 128 KB
One Zone-IA Milliseconds Synchronous GET Yes 30 days 128 KB
Intelligent-Tiering (frequent/infrequent/archive instant tiers) Milliseconds Synchronous GET No (per-object monitoring fee instead) None Objects under 128 KB are not auto-tiered
Glacier Instant Retrieval Milliseconds Synchronous GET Yes, higher than IA 90 days 128 KB
Glacier Flexible Retrieval Minutes to hours Restore, then GET Yes, depends on retrieval tier 90 days Per-object metadata overhead
Glacier Deep Archive Hours Restore, then GET Yes 180 days Per-object metadata overhead

The billing floors have direct consequences:

  • Early deletion still costs the full minimum. If you delete or overwrite an object 10 days after it enters Standard-IA, you are billed for the full 30 days. Short-lived API artifacts can cost more in IA than in Standard.
  • Small objects are billed as 128 KB. A 4 KB thumbnail in Standard-IA is billed as if it were 128 KB, which wipes out the lower per-GB rate.
  • A restore is not a read. Glacier Flexible Retrieval and Deep Archive return an error on GET until a restore finishes. An endpoint that serves objects on request cannot sit in front of them.
  • One Zone-IA keeps data in a single Availability Zone. If that zone is lost, the data is lost with it. Use it only for data you can regenerate, such as derived renditions or caches.

Moving data to a colder class is not the only option. Many workloads have hot, small, or short-lived objects, and for those staying in Standard is the cheapest choice. Other options include expiring data you no longer need, compressing or batching small objects before they are stored, and deleting old noncurrent versions.

How do you profile access patterns before writing lifecycle rules?

Lifecycle rules encode an assumption about when data goes cold, so check that assumption against real access data first. Three S3 features cover this at different levels of detail.

Storage Class Analysis is configured per bucket and can filter by prefix or tag. It watches retrieval activity relative to object age, and after observing for about a month it suggests the age at which a transition to Standard-IA looks safe. It only evaluates Standard-IA, so use it as a starting point, not a final answer.

Storage Lens gives account- or organization-wide views of bytes and object counts per storage class and bucket. Use it to rank buckets by size and find where tuning is worth the effort. A bucket holding a few gigabytes rarely justifies the work, while one growing by terabytes a month usually does.

Server access logs record individual requests. Delivery is best-effort, but over a few weeks they show which prefixes get read and how old the objects are when they are fetched.

The analysis only works if your keys separate data with different lifetimes. Lifecycle filters match on prefix, object tags or object size. Put lifetime in the key layout, such as exports/, uploads/raw/ and logs/, rather than tenant-id/ at the top level, which mixes every data type under one prefix. Tags are more flexible but have a per-object monthly charge and require your application to set them on write.

Restructuring keys after billions of objects exist means copying data, which costs requests and engineering time. Choosing the layout early avoids that work.

+--------------------------------------------------------------+
| S3 bucket: keys grouped by data lifetime                     |
|  exports/        uploads/raw/        logs/     (+ tags)      |
+--------------------------------------------------------------+
        |                    |                     |
        v                    v                     v
+----------------+  +-------------------+  +------------------+
| Storage Lens   |  | Storage Class     |  | Server access    |
| bytes/objects  |  | Analysis          |  | logs             |
| per bucket and |  | per prefix or tag |  | per request,     |
| storage class  |  | age vs. retrieval |  | best-effort      |
+----------------+  +-------------------+  +------------------+
        |                    |                     |
        v                    v                     v
 Which buckets are    Suggested age for     Which prefixes are
 worth tuning?        Standard-IA move      read, at what age?
        |                    |                     |
        +--------------------+---------------------+
                             |
                             v
          +--------------------------------------+
          | Lifecycle rules per prefix/tag/size  |
          |  logs/: transition, then expire      |
          |  uploads/raw/: expire early          |
          +--------------------------------------+

Prefixes that separate data by lifetime let Storage Lens, Storage Class Analysis and server access logs measure each data type separately, and those measurements then set the transition and expiration ages in each lifecycle rule.

How do S3 lifecycle rules work?

A lifecycle configuration is a set of rules attached to a bucket. S3 applies it in the background. Your application does not call anything at read or write time, and no code runs in your account.

Each rule has three parts:

  • A filter that selects objects by key prefix, object tags, object size, or a combination using And. An empty filter matches every object in the bucket.
  • A status, Enabled or Disabled, so you can keep a rule defined without it acting.
  • One or more actions: transitions to another storage class, expiration of current versions, expiration or transition of noncurrent versions, removal of expired delete markers, and aborting incomplete multipart uploads.

Ages are measured in days from the object's creation, or for noncurrent actions, from when the version became noncurrent. S3 evaluates the rules periodically, determines which objects have become eligible, and queues the actions. The work happens asynchronously, so an object can stay in its old class or remain visible for some time after the day it qualified.

Transitions only move data "down" towards colder classes. Lifecycle does not move an object from Standard-IA back to Standard. Lifecycle also enforces some limits on transitions. For example, an object must have been stored for at least 30 days before a rule can move it to Standard-IA or One Zone-IA. Size filters let you exclude small objects so they are never moved into a class with a 128 KB billing floor.

When several rules match the same object, S3 resolves conflicts in favour of the action that costs less. Expiration takes precedence over transition, and a transition to a colder class takes precedence over one to a warmer class. Object Lock retention and legal holds still override expiration.

How do you write S3 lifecycle rules that do the work?

Write one rule per data class rather than one rule per bucket. A rule's filter can match a key prefix, an object tag, or both combined with And. That is why the key layout from the previous section matters: exports/ and uploads/raw/ can carry different policies without the application doing anything at read time.

The configuration example that follows has four parts.

  • Transitions move objects to a cheaper class after N days. Set N from the access profile you measured, not from a default.
  • Expiration deletes current objects. On a versioned bucket it adds a delete marker instead, so storage keeps billing.
  • NoncurrentVersionExpiration removes the old versions that would otherwise accumulate.
  • ExpiredObjectDeleteMarker cleans up the leftover markers. It cannot share a rule with a day-based Expiration, so give it its own rule.

Add a bucket-wide AbortIncompleteMultipartUpload rule. Parts from failed uploads are billed as storage but never show up in a normal object listing.

Apply the configuration with aws s3api put-bucket-lifecycle-configuration --bucket <name> --lifecycle-configuration file://lifecycle.json. This call replaces the bucket's entire existing configuration. Fetch the current rules first with get-bucket-lifecycle-configuration and merge your changes into them.

Lifecycle actions run asynchronously, so objects move or disappear some time after they become eligible. Test new rules on a non-production bucket or a narrow prefix before rolling them out.

Expiration cannot be undone. An empty or overly broad filter on an expiration action will delete every object it matches. Keep the lifecycle file in version control, record the reason for each rule, and review the rules whenever the key layout changes.

#!/usr/bin/env bash
set -euo pipefail
BUCKET="example-api-data-staging"  # test on a non-production bucket first

aws s3api get-bucket-lifecycle-configuration --bucket "$BUCKET" \
  > lifecycle.backup.json || echo "no existing lifecycle configuration"

cat > lifecycle.json <<'EOF'
{"Rules": [
  {"ID": "exports-tiering", "Status": "Enabled",
   "Filter": {"Prefix": "exports/"},
   "Transitions": [{"Days": 30, "StorageClass": "STANDARD_IA"},
                   {"Days": 90, "StorageClass": "GLACIER"}],
   "Expiration": {"Days": 365},
   "NoncurrentVersionExpiration": {"NoncurrentDays": 30}},
  {"ID": "raw-uploads-temp", "Status": "Enabled",
   "Filter": {"And": {"Prefix": "uploads/raw/",
     "Tags": [{"Key": "retention", "Value": "temp"}]}},
   "Expiration": {"Days": 7},
   "NoncurrentVersionExpiration": {"NoncurrentDays": 1}},
  {"ID": "exports-delete-markers", "Status": "Enabled",
   "Filter": {"Prefix": "exports/"},
   "Expiration": {"ExpiredObjectDeleteMarker": true}},
  {"ID": "abort-incomplete-mpu", "Status": "Enabled",
   "Filter": {"Prefix": ""},
   "AbortIncompleteMultipartUpload": {"DaysAfterInitiation": 7}}
]}
EOF

aws s3api put-bucket-lifecycle-configuration --bucket "$BUCKET" \
  --lifecycle-configuration file://lifecycle.json
aws s3api get-bucket-lifecycle-configuration --bucket "$BUCKET"

Backs up existing rules, then applies a lifecycle configuration with prefix and tag filters, transitions, expiration, noncurrent version cleanup, delete-marker removal and multipart upload aborts.

When should you use Intelligent-Tiering, and when should you avoid it?

Intelligent-Tiering moves each object between access tiers based on its own observed access. Objects not read for 30 consecutive days move to an Infrequent Access tier, and after 90 days to an Archive Instant Access tier. A read moves an object back to the frequent tier. There are no retrieval fees for these automatic tiers. Instead you pay a monthly monitoring and automation fee per object.

Use it when you cannot predict access, or when access shifts over time. Examples include user uploads where a small, unpredictable subset stays popular, or exports that customers may re-download months later. Explicit rules handle that kind of data badly because one age threshold cannot fit every object.

The fee is what makes small objects a poor fit. Objects under 128 KB are not monitored and stay billed at frequent-tier rates, so they gain nothing. Objects just above that size pay the monitoring fee on very little storage, and the fee can cancel out the discount. For data that decays predictably, such as logs or request archives that are rarely read after a week, an explicit lifecycle rule produces the same transitions without a monthly per-object charge.

The optional Archive Access and Deep Archive Access tiers are opt-in. Objects in those tiers need a restore before an API can read them, and a restore takes hours rather than milliseconds. Enable them only for data that no request path reads synchronously.

Situation Better choice
Unknown or shifting access, objects well above 128 KB Intelligent-Tiering
Predictable age-based decay Explicit lifecycle rules
Mostly small objects, or hot data Stay in Standard
Data an API must read synchronously Avoid the opt-in archive tiers

What are the alternatives to lifecycle rules?

Lifecycle rules are not the only way to control S3 cost, and for some workloads another approach is simpler or cheaper.

  • Choose the storage class at write time. A PUT can set the storage class directly, for example writing data that is known to be cold straight into Standard-IA or a Glacier class. This skips the transition request entirely. It only makes sense when the read pattern is known when the object is created and the object is large enough to clear the class's minimum billable size.
  • Intelligent-Tiering. As covered above, it replaces fixed age thresholds with per-object access tracking. It suits unpredictable access on larger objects.
  • Application-driven deletion. The application or a scheduled job deletes objects when the business event that justified them ends, such as an account closing or an export link expiring. This is more precise than an age-based rule but costs DELETE requests and code you must maintain. Lifecycle expiration does not charge per-object delete requests.
  • S3 Batch Operations. For a one-off cleanup or reclassification of an existing set of objects, such as a backlog from before rules existed, a batch job driven by an inventory list can copy, tag, or otherwise act on objects. It is a migration tool, not an ongoing policy.
  • Compress or aggregate small objects. Batching many small JSON payloads or log lines into larger compressed files reduces request counts, transition counts, and the impact of 128 KB billing floors. It changes how readers access the data, so it fits archival and analytics paths better than per-item API reads.
  • Keep small, short-lived data out of S3. Tiny records with a short lifetime may be cheaper in a cache or a database with built-in expiry than as individual objects that each incur a PUT.
  • Do nothing. For small buckets, hot data, or mostly tiny objects, staying in Standard with no rules beyond multipart cleanup is often the cheapest outcome.

These approaches combine well. A common pattern is to set the class at write time for known-cold data, use lifecycle expiration for retention, and reserve Intelligent-Tiering for the prefixes where access cannot be predicted.

Does transitioning to Standard-IA actually save money? A worked break-even estimate

Illustrative estimate (assumed numbers, not a benchmark). Substitute your region's current unit prices for the placeholders.

Assumed inputs: 10,000,000 objects older than 30 days, average size 500 KB (≈5,000 GB), none under 128 KB, growth of 1,000,000 objects per month, and 1% of aged data read per month (50 GB).

Option Recurring monthly cost One-time cost Read cost
Stay in Standard 5,000 × P_std none GET requests only
Standard-IA at 30 days 5,000 × P_ia 10,000 × T_req (per 1,000 transitions) 50 × R_ia plus higher GET price
Intelligent-Tiering 5,000 × tier price + 10,000 × M_it 10,000 × T_req no retrieval fee

The break-even for Standard-IA works like this:

  • Monthly saving = GB × (P_std − P_ia) − GB_read × R_ia
  • Break-even months = (objects ÷ 1,000 × T_req) ÷ monthly saving

New growth adds another 1,000 × T_req each month, so include it in the recurring side.

The minimum billable size changes this result. Each object under 128 KB is billed as 128 KB in Standard-IA. A 20 KB object therefore costs more than it would in Standard, and the request fee still applies. If your average size hides many small objects, filter them out of the rule by size.

A read spike, such as a backfill or a customer export, can erase the savings. One full read of the aged set costs 5,000 × R_ia. That equals R_ia ÷ (P_std − P_ia) months of savings. When that ratio is near 1, every export costs you a month of savings. If exports happen often, Intelligent-Tiering, which charges no retrieval fee, or staying in Standard comes out cheaper.

Why is retention the biggest lever, and how do you verify the savings?

Class tuning trims a percentage off each byte. Expiration removes the byte entirely. A rule that deletes request logs after 30 days because nobody queries them later cuts more than moving those logs to a cheaper class ever could. Set each prefix's retention from a named requirement, such as a product feature, a contractual SLA, or a regulation, and record that owner next to the rule.

Versioning undermines this quietly. On a versioned bucket, an expiration action on current versions only adds a delete marker, and every overwrite leaves a noncurrent copy behind. Without a noncurrent-version expiration rule, a frequently rewritten object can accumulate many billable copies that never show up in normal listings.

Compliance can also block deletion. Object Lock retention periods and legal holds take precedence over lifecycle expiration, so locked versions stay and keep billing. Agree with legal on which prefixes are locked before you promise any savings.

Verifying after rollout

Lifecycle rules run asynchronously, so expect a lag of a day or more before transitions and expirations show up. After that:

  • Watch the daily per-storage-class bucket size and object count metrics. Bytes should move between classes or drop.
  • Check request metrics for new retrieval or transition charges.
  • Compare the bill's storage, request, and retrieval line items across a full billing cycle.

Re-check assumptions whenever a feature changes how objects are read. A review takes an engineer an hour or two each quarter. That ongoing cost is small, but it is easy to drop, and when it lapses the one-off savings decay.

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to s3 lifecycle cost savings, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Reviewers see the exact diff and the list of affected services up front, so approval is a decision rather than an investigation.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • Per-service approve/reject means a bad shared value can be refused where it would break something, before it is live.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.