S3 object storage
The S3 service provides an S3-compatible object store for buckets, objects, and bucket controls. It accepts REST-XML requests, maps path-style and virtual-hosted requests to the same resources, checks credentials and resource permissions, and then reads or changes stored state. It also supports multipart uploads, versions, websites, notifications, S3 Select, lifecycle cleanup, browser uploads, object annotations, and S3 Control account settings. See IAM and authentication for the shared identity boundary.
Service boundaries
The service has three related API surfaces. The general S3 API manages bucket and object resources. The S3 Control API manages account-scoped public-access settings and selected resource queries. The S3 Vectors API manages vector buckets, indexes, and vector data as separate account and region resources.
| Surface | Main role | State scope |
|---|---|---|
| General S3 API | Bucket, object, version, multipart, website, Select, annotation, and bucket-setting operations | Bucket and object |
| S3 Control API | Account public-access settings, access-point listing, and resource tags | AWS account or bucket resource |
| S3 Vectors API | Vector bucket, index, vector data, policy, and tag operations | Account, region, vector bucket, and index |
Successful object changes can send events to SQS, SNS, Lambda, and EventBridge. S3 data events can also reach CloudTrail. These downstream effects follow the storage change and do not replace it.
References: src/…/S3Controller.java• L217-269 src/…/S3Service.java• L245-268 src/…/S3Service.java• L6387-6475
S3 Vectors resources
The S3 Vectors API stores vector buckets that contain indexes. An index defines the vector shape and distance method, then holds keyed vectors with optional metadata for write, read, list, delete, and nearest-neighbor query operations.
Requests identify a vector bucket by exactly one of its name or ARN. They identify an index by its bucket and index names or by its index ARN. ARN requests must match the caller's partition, region, and account. Bucket and index tags are part of the resource context used by IAM tag conditions, so policy checks can target the resource that the request names.
Vector bucket and index tags support create-time values, full replacement, and shared REST TagResource, UntagResource, and ListTagsForResource operations. Tag updates merge by key or remove named keys, while the service validates tag names, values, and the 50-tag limit. The shared handler uses strict payload validation and returns the S3 Vectors service's successful status for these operations.
References: src/…/S3VectorsController.java• L304-550 src/…/S3VectorsService.java• L85-203 src/…/S3VectorsService.java• L225-263 src/…/S3VectorsService.java• L400-650 src/…/VectorBucket.java• L10-47 src/…/VectorIndex.java• L11-67 src/…/S3VectorsTagHandler.java• L10-53
Bucket state
Each bucket is a named resource with a region and optional controls. The controls stay with the bucket so later requests use the same rules after a restart.
| State area | Purpose |
|---|---|
| Region and creation time | Identifies the bucket and its location |
| Versioning and object lock | Controls object history and retention protection |
| Policy and ACL | Defines access for signed and anonymous callers |
| Tags and notification settings | Supports labels and object event targets |
| Website, CORS, logging, lifecycle, encryption, replication, payment, ownership, acceleration, and public-access settings | Defines optional bucket behavior exposed by S3 sub-resources |
| Metrics, Intelligent-Tiering, analytics, and inventory configurations | Stores named rules that other AWS systems can read |
The bucket also records whether its public-access block was explicitly deleted. This keeps an explicit delete distinct from a bucket that never had that configuration.
Bucket creation can apply a region and initial tags. Repeated creation is idempotent only for the default S3 region. A different region returns an ownership conflict. Bucket deletion requires an empty bucket.
When the global bucket namespace is enabled, bucket reads and bucket configuration updates can resolve the bucket in its owning account. The update is written back to that account, while bucket creation and deletion remain scoped to the caller's account. This models globally unique bucket names without moving account-level controls into the global namespace.
Metrics, Intelligent-Tiering, analytics, and inventory configurations are record-only features. The service validates their XML, stores each configuration by its ID, returns a stable form for reads and lists, and does not create reports, metrics, or tier movement.
Bucket listing supports an optional max-buckets limit and continuation token. Results are ordered by bucket name and can be paged up to 10,000 buckets per requested page. A request without max-buckets returns the complete visible list, while invalid or cross-account continuation tokens fail as InvalidArgument.
References: src/…/S3Service.java• L539-684 src/…/S3Controller.java• L263-291 src/…/S3Controller.java• L303-492 src/…/S3Controller.java• L497-586 src/…/S3Service.java• L627-635 src/…/S3Service.java• L7535-7601 src/…/S3Service.java• L3710-4013 src/…/Bucket.java• L14-40 src/…/Bucket.java• L120-140
Lifecycle expiration
Bucket lifecycle rules define delayed cleanup for objects and incomplete multipart uploads. The service stores the lifecycle document with the bucket, evaluates enabled rules against object key, tags, and size, and applies due expiration in a background sweep rather than during the request that reads the object.
Lifecycle rules support these expiration actions:
- Current-version expiration by age or date.
- Removal of an expired object delete marker.
- Permanent removal of noncurrent versions by age or by the number of newer versions.
- Abortion of incomplete multipart uploads after their initiation age.
Rules can use a prefix, object tags, and exclusive size bounds. Transition actions are not modeled. Invalid stored documents or rules are ignored during evaluation, while disabled rules do not apply. The current object response can include an x-amz-expiration value when an enabled rule has a future age or date for that version.
The lifecycle worker starts only when S3 and lifecycle sweeping are enabled. It runs at a fixed delay, uses a default of 60 seconds for a non-positive interval, and continues with later runs after a sweep error. It scans buckets in their owning accounts, rechecks the object and rule state before acting, and does not remove data protected by object-lock retention or legal hold.
This diagram shows how stored lifecycle rules become asynchronous object or multipart cleanup.
flowchart LR
A[Stored bucket lifecycle rules] --> B[Background sweep]
B --> C[Match key tags size and age]
C --> D{Action due}
D -->|Object or version| E[Apply S3 delete semantics]
D -->|Incomplete multipart upload| F[Abort upload]
D -->|No| G[Leave state unchanged]
E --> H[Lifecycle event]
F --> H
Lifecycle deletion follows normal version and delete-marker semantics. It can create a delete marker for a current object in a versioned bucket or permanently remove a named version. Downstream S3 event records identify the lifecycle service as the requester and use Lifecycle Expiration as the EventBridge reason.
References: src/…/S3Service.java• L4990-5349 src/…/S3Service.java• L6513-6527 src/…/S3Service.java• L6582-6628
Object state
An object joins a bucket key with content and the metadata needed for S3 reads. The service keeps object metadata separate from object bytes. This lets metadata operations and body operations use the same object identity without placing large content in the metadata record. Reads open one object snapshot so metadata and bytes belong to the same write.
Object state includes:
- Content size, type, cache and download headers, and user metadata.
- ETag, checksum values, storage class, and multipart part details.
- Tags, ACL data, encryption markers, and object-lock retention state.
- An optional version ID, latest marker, and delete-marker state.
- Internal write-generation and event-sequencer values used for consistent reads and event order.
- Named annotations attached to one object version.
An object annotation is a named UTF-8 payload attached to a specific object version. It has its own size, ETag, checksum, timestamp, and inherited encryption marker. An object version can have up to 1,000 annotations, each with a payload up to 1 MiB. Annotation bodies use separate storage from annotation metadata, and annotation writes and deletes produce object annotation events. Annotations cannot be added to SSE-C objects and follow the parent version's retention and legal-hold rules.
Versioning changes the meaning of writes and deletes. A write creates a new version and makes it current. A delete without a version ID creates a delete marker. A delete with a version ID removes that version. Content written before versioning was enabled keeps the special null version shown by S3 version listings. A current delete marker makes an ordinary object read behave like a missing key, while a request that names the marker version is rejected as a method-not-allowed resource.
Each visible write also has an internal generation used to keep a concurrent read from pairing old metadata with new bytes. A stored event sequencer records write order for object events and version promotion. These values support consistent state and event ordering; they are not new S3 request fields.
Version listing can continue from a version that a client deleted after receiving an earlier page. The service keeps a bounded recent position for deleted versions, so a later version-id-marker can resume after that version instead of repeating the page. If that position is no longer available, the remaining versions of the marker key are listed.
Checksums identify the data form that S3 reports. Supported algorithms are CRC32, CRC32C, CRC64NVME, SHA1, and SHA256. Multipart checksum type rules vary by algorithm. When no algorithm is declared for a multipart part, the service uses CRC64NVME.
References: src/…/S3Object.java• L17-67 src/…/ObjectAnnotation.java• L13-37 src/…/S3DeleteMarkerException.java• L9-38 src/…/S3Service.java• L897-1081 src/…/S3Service.java• L1939-1994 src/…/S3Service.java• L2600-2644 src/…/S3Service.java• L3218-3314 src/…/S3Service.java• L3442-3512 src/…/ChecksumAlgorithm.java• L13-129 src/…/S3Controller.java• L976-1127
Object reads and ranges
Object GET and HEAD requests use the same object snapshot for metadata, conditions, and body output. They support one byte range at a time and can also address one stored multipart part with partNumber, so clients can read part of an object without loading or returning the full body.
Range and part behavior is controlled by the Range, If-Range, and partNumber inputs:
- A valid byte range returns
206withContent-Rangeand the selected length. - A suffix range is resolved from the object end. An unsatisfied range returns
416with the object size. - A malformed or unsupported range is treated as a normal whole-object request.
- A matching ETag or exact
Last-Modifieddate allows the range. Any otherIf-Rangevalue returns the whole object. - A
partNumberrequest cannot also includeRange. A valid part is served as the corresponding slice and reports the multipart part count. - Part numbers below one are invalid arguments. A part that the object does not have returns
416with the requested and actual part counts. - A stored checksum is returned for a range only when it describes that exact returned data.
- A GET or HEAD that names a delete marker by version returns
405with delete-marker identity and time information. A read of the current marker returns404 NoSuchKeyinstead.
The same bounded read model serves source ranges for multipart copy. The copy validates the source size before it reads and stores only the requested bytes.
References: src/…/S3Controller.java• L976-1326 src/…/S3Controller.java• L3813-3848 src/…/S3Service.java• L1772-1906
Storage state
The service stores bucket, object, and annotation metadata in the shared storage system. It stores object and annotation bodies in memory or on disk according to the S3 storage mode. Multipart parts use the same body store until completion or abort. Disk-backed writes stage streamed bodies first, then publish the body and metadata as one object state change.
Persistent mode keeps metadata and bodies across restarts. Changing the storage mode does not move existing bodies between memory and disk. When the global bucket namespace is enabled, reads can resolve a bucket across account partitions while writes keep the bucket and its object state in the owning account partition. Account-level public-access settings and annotation state remain partitioned by account.
S3 also provides tagged, account-scoped scratch buckets for internal data transfers. These buckets are created only when needed, are hidden from normal bucket listings, and are accepted only when their expected internal tag is present. Each transfer type has a narrow object or prefix scope, so its temporary credentials cannot use the scratch bucket as a general-purpose bucket.
See storage backend for the shared persistence model.
References: src/…/S3Service.java• L164-302 src/…/S3Service.java• L474-520 src/…/S3Service.java• L550-673 src/…/S3ScratchSpace.java• L13-71 src/…/S3Service.java• L7535-7625
REST request handling
The general S3 API uses REST-XML routes with one bucket path and one bucket-plus-key path. The HTTP verb and query string select the bucket or object sub-resource. The service authorizes the selected action before it reads or changes state.
Each verb and query combination is resolved before the base bucket action. Implemented sub-resources are handled directly. The remaining bucket sub-resources are derived from the vendored AWS route model; a defined but unsupported operation returns NotImplemented, while a sub-resource used with a method AWS does not define returns MethodNotAllowed. This prevents an unknown query from falling through to bucket creation, listing, or deletion.
Query flags are checked in both the decoded parameter map and the raw query string, so a flag-only form such as ?uploads still selects its sub-resource. The raw query is split on literal & before a query name is decoded, so an encoded separator inside a value does not create a false sub-resource. Object writes can decode AWS chunked bodies as they arrive and validate Content-MD5 or S3 checksum headers before publishing the object. GET and HEAD requests apply conditional reads, byte ranges, response-header overrides, and checksum reporting to the same object snapshot.
AWS chunked bodies are decoded as a stream when the request declares a streaming payload or a checksum trailer. The decoder consumes chunk framing and the final trailer block without storing the whole framed body. It requires complete framing, rejects an undersized non-final chunk, and retains only the checksum named by x-amz-trailer; an undeclared checksum trailer is not accepted as a valid upload claim. The aws-chunked transfer marker is not persisted as object content encoding.
Object creation authorization also follows the settings on the request. ACLs, tags, retention, and legal holds can require separate S3 actions and can expose tag or lock values to policy conditions. Inline tags can come from either the x-amz-tagging header or the equivalent presigned-URL query value. A copy reads source conditions before it writes the destination. It can preserve or replace metadata, tags, and annotations according to its directives.
S3 resource authorization uses the same object key that the handler acts on. For object routes, the resource labels preserve the key from the request path when router normalization would remove a leading or repeated slash, so IAM checks and storage do not address different objects.
The request path follows this sequence:
flowchart LR
A[HTTP request] --> B[Host and path normalization]
B --> C[REST-XML route]
C --> D[Sub-resource selection]
D --> E[Credential and request signature checks]
E --> F[Bucket or object authorization]
F --> G[S3 state read or change]
G --> H[XML or object response]
G --> I[Events and audit records]
Bucket operations cover creation, deletion, listing, location, versioning, tags, policies, ACLs, public access block, website settings, encryption, lifecycle, replication, metrics, Intelligent-Tiering, analytics, and inventory. Object operations cover upload, download, head, delete, copy, tagging, annotations, ranges, checksums, object attributes, multipart work, object-lock controls, and Select queries.
Multipart upload creates an upload record, accepts numbered parts, and publishes one object only after completion. The record keeps the bucket owner and initiating account so later list, part, completion, and abort requests cannot use another account's upload. It also carries the object tags, checksum mode, access settings, encryption settings, and lock settings that apply when the object is published. Completion and abort remove the temporary upload state after their result is fixed. A presigned POST accepts a browser form after policy and signature checks. Its form credential also goes through IAM authorization when present. Website requests use configured index and error documents instead of REST-XML errors.
CORS preflight requests are evaluated against the bucket's CORS rules and return the allowed methods and headers or an S3 XML error. Matching actual requests receive the allowed origin, credentials, Vary, and exposed-header response values. Signature validation skips a CORS preflight because its method is not the method signed for the follow-up request.
References: src/…/S3Controller.java• L303-802 src/…/S3Controller.java• L813-974 src/…/S3Controller.java• L4082-4271 src/…/S3Controller.java• L4612-4635 src/…/S3ObjectActions.java• L56-169 src/…/S3BucketSubresources.java• L14-59 src/…/S3QueryParams.java• L7-27 src/…/S3RequestParser.java• L21-73 src/…/AwsChunkedInputStream.java• L13-21 src/…/S3RequestPathLabels.java• L13-50
Request paths
Path-style and virtual-hosted-style requests address the same bucket and object state. The virtual-host route maps a bucket host to the path form used by the REST routes. It recognizes region, website, dual-stack, acceleration, and custom-host forms while leaving S3 Control and other AWS service requests outside the bucket route.
The route uses the first X-Forwarded-Host value when a reverse proxy carries the client host. Otherwise it uses the Host header or the HTTP/2 authority. It keeps the original URI available for signature checks when it rewrites a request. Object key extraction uses the raw path as sent by the client, so leading slashes, repeated path segments, encoded separators, and literal plus signs keep their S3 meaning instead of using the normalized framework path. A key made only of slashes is also kept on the object route rather than being mistaken for a bucket request. This makes host parsing and key parsing part of the authorization contract, not only a routing convenience.
The same raw key is also supplied to IAM resource construction. This keeps a path such as /{bucket}//key tied to the object key /key in routing, storage, and policy matching.
| Request form | Resource interpretation |
|---|---|
/{bucket}/{key} | Path-style bucket and object request |
{bucket}.<endpoint>/{key} | Virtual-hosted bucket and object request |
{bucket}.s3.<region>.<endpoint>/{key} | Region-qualified virtual-hosted request |
{bucket}.s3-website-<region>.<endpoint>/{key} | Website request |
/v20180820/... | S3 Control request, not a bucket request |
Bucket names with dots remain intact. The filter avoids hosts that belong to other AWS services and uses a signed request's existing bucket name as a fallback on a custom host. A bare S3 service endpoint is not treated as a bucket named s3. The route also avoids region-shaped labels that belong to other regional service hosts, while preserving valid bucket names that only resemble such labels.
References: src/…/S3VirtualHostFilter.java• L119-186 src/…/S3VirtualHostFilter.java• L222-319 src/…/S3VirtualHostFilter.java• L388-431 src/…/S3VirtualHostFilter.java• L502-597 src/…/S3ObjectKeys.java• L7-79 src/…/S3SlashOnlyKeyFilter.java• L21-81 src/…/S3RequestPathLabels.java• L21-50 src/…/S3Controller.java• L4565-4587
Signed request paths
S3 supports three credential placements. An ordinary SDK request carries SigV4 or SigV4A in the Authorization header. A presigned URL carries the same type of authorization in query parameters. A presigned POST carries a policy and its signing fields in a browser form.
The S3 signature filters run only for requests routed to the general S3 controller. They verify signatures when authentication enforcement or signature validation is enabled. CORS preflight is excluded because its OPTIONS method is not the method signed for the follow-up request. This scope prevents S3 signing rules from being applied to S3 Control or another AWS service that shares the HTTP boundary. Authentication proves the credential and request contents; S3 resource authorization still decides whether the action is allowed.
Header-based SigV4 checks the request date, credential scope, access key, session token, clock skew, signed headers, and x-amz-content-sha256. SigV4A uses a region-less credential scope and requires the signed x-amz-region-set header. Both forms use the request's wire path and encoded query when building the canonical request. A real signed payload hash is checked against the body, while unsigned and streaming payload markers retain their special meaning.
Generated presigned URLs use the current request account as the credential identity and the request region in the credential scope. When IAM is available, the generator creates or reuses a short-lived temporary credential and registers a policy limited to the URL's object and operation. Replaced credentials remain available until their earlier URLs expire. The URL lifetime cannot exceed seven days. Outside a request, the configured account and region provide the defaults.
URL issuance and validation use the same canonical request rules for the method, wire path, query string, signed headers, authority, and payload marker. The validator preserves the original request URI when virtual-host rewriting changes the framework route. A valid signature proves request authenticity but does not replace normal S3 resource authorization.
Presigned URL validation resolves registered IAM credentials and their session tokens. Under authentication enforcement, an unregistered account-shaped access key is not accepted as a substitute credential. This prevents a caller from choosing an account ID and a shared fallback secret to sign for another account.
Presigned URLs must include every supported checksum and user-metadata header in X-Amz-SignedHeaders. An unsigned checksum or user-metadata header is rejected. If a request signs Range, its qualifying If-Range header must also be signed.
Presigned POST validates the multipart form's policy, credential scope, date, signature, expiry, key, and policy conditions before it stores the object. The form credential is checked against IAM even though it is not available to the normal request filter. An expired temporary session returns ExpiredToken; a valid signature still must pass the normal S3 object-write authorization.
This diagram shows the two presigned request paths and their shared authorization boundary.
flowchart LR
A[Presigned URL] --> B[Query credential and canonical request]
C[Presigned POST] --> D[Form credential and policy]
B --> E[Signature validation]
D --> E
E --> F[IAM and S3 resource authorization]
F --> G[Object operation]
References: src/…/S3SignatureFilterScope.java• L11-19 src/…/S3HeaderSignatureFilter.java• L34-80 src/…/S3HeaderSignatureFilter.java• L122-235 src/…/PreSignedUrlFilter.java• L83-220 src/…/PreSignedUrlFilter.java• L252-318 src/…/PreSignedUrlGenerator.java• L112-198 src/…/PreSignedUrlGenerator.java• L217-297 src/…/S3RequestAuthorizationParser.java• L35-132 src/…/S3ResourceArns.java• L5-21 src/…/S3PostPolicySigner.java• L31-103 src/…/S3Controller.java• L4228-4271
Access controls
S3 access combines credential checks with resource policy checks. Signed requests use a known access key and then pass through bucket and object authorization. Unsigned requests need a matching public policy or ACL when authentication enforcement is enabled. When enforcement is disabled, credential and policy checks do not block the request, but Block Public Access still rejects public ACL or policy writes.
The access decision uses these layers:
- SigV4 or SigV4A credential validity for signed requests.
- IAM identity policy and S3 bucket resource policy decisions for named principals.
- Bucket and object ACL grants, including the public
AllUsersandAuthenticatedUsersgroups. - Canonical-user grants for CloudFront origin access identity requests.
- Bucket and account public-access-block settings.
- Object-lock retention and legal-hold rules for protected changes.
- Internal scratch scopes for service-managed transfer sessions.
S3 bucket policies enter the IAM resource-policy path only for S3 resources. Bucket and object policy resources use partition-aware S3 ARNs with no region or account segment. The same resource form is used for direct requests, presigned URLs, and selected service-to-service reads. A policy on an existing bucket is not used to grant CreateBucket, because creation has no existing bucket policy to consult.
Object operations that set tags or Object Lock values also expose those values to the matching IAM condition keys. Bucket listings expose s3:prefix as the request condition, including an empty value when no prefix is supplied. A request with a version ID uses the version form of actions that support it. This keeps authorization aligned with the version or object that the operation changes.
The four Block Public Access flags have separate effects. BlockPublicAcls rejects a submitted public ACL. IgnorePublicAcls stops stored public ACLs from granting access. BlockPublicPolicy rejects a new public bucket policy. RestrictPublicBuckets limits access through a public bucket policy to the owner account. Bucket and owner-account settings combine per flag by taking the more restrictive value. A wildcard policy with a fixed, narrowing condition is not treated as public for this status decision. A wildcard aws:PrincipalArn condition may use a fixed account ARN and still remain non-public when it narrows access to that account.
An explicit policy deny wins over an allow. A public bucket policy or object ACL can allow anonymous reads. A public bucket ACL can allow a new object write, but it does not grant permission to overwrite an existing object. Object lock adds a second protection layer. Legal holds and compliance retention block protected changes. Governance retention needs the matching bypass permission.
References: src/…/S3PublicAccessEvaluator.java• L113-181 src/…/S3PublicAccessEvaluator.java• L184-261 src/…/S3AclPublicAccessEvaluator.java• L15-81 src/…/S3ResourcePolicyProvider.java• L12-99 src/…/S3ConditionKeys.java• L7-21 src/…/S3ResourceArns.java• L5-21 src/…/S3ScratchSpace.java• L42-71 src/…/S3Service.java• L1159-1671 src/…/S3Service.java• L6119-6230 src/…/S3Controller.java• L1833-1882 src/…/S3RequestPathLabels.java• L38-50
Multipart and object protection
Multipart upload separates a large write into an upload record and numbered parts. Completion joins the selected parts into one normal object, records the result checksum and part data, sends the object-created event, and removes the temporary upload state. Abort removes the temporary state without creating an object.
The upload record carries the object settings that apply at completion. This includes metadata, tags, encryption choices, ACL grants, Object Lock settings, checksum algorithm and type, bucket owner, and initiating account. A part replacement changes the selected part while leaving other parts available. Completion requires ascending part numbers, matching part ETags and checksums when supplied, valid size limits, and a matching final checksum. Multipart operations for one upload are serialized so a part write, completion, and abort cannot publish conflicting temporary state.
Streamed parts pass through digest checks before they are published into the upload. A declared Content-MD5 or checksum that does not match the body fails the part or object write. For AWS chunked uploads, x-amz-trailer can name a checksum that must appear and match in the decoded trailer.
Copy source conditions are checked before reading the source. Destination preconditions protect the target write. Object-lock retention and legal holds apply to overwrite, delete, and annotation changes.
This diagram shows the multipart state change from an upload record to a published object.
flowchart LR
A[Create multipart upload] --> B[Store numbered parts]
B --> C{Complete or abort}
C -->|Complete| D[Validate order ETags checksums and size]
D --> E[Publish one object]
C -->|Abort| F[Remove temporary upload state]
E --> G[Object-created event]
References: src/…/S3Controller.java• L877-967 src/…/S3Controller.java• L1603-1727 src/…/S3Service.java• L4168-4511 src/…/S3Service.java• L4530-4750 src/…/S3Service.java• L4788-4907 src/…/S3Service.java• L5146-5219 src/…/MultipartUpload.java• L27-145 src/…/ChecksumAlgorithm.java• L13-86 src/…/AwsChunkedInputStream.java• L103-156
S3 Select queries
S3 Select reads a query from one object and returns only the selected records. The request opens the object and its metadata as one read snapshot, then sends records through an AWS event stream with statistics and an end event.
The service accepts CSV, JSON, and Parquet input. It uses the Duck query service when the input form supports that path and uses a bounded evaluator for other CSV and JSON queries. The evaluator supports projection, predicates, and LIMIT; unsupported predicates fail as request errors, and a record larger than 1 MB stops the stream with an S3 Select error.
The response can serialize records as CSV or JSON. A limit can stop the read before the object ends, so the reported scanned bytes describe the part of the object that the query read. Errors found after records have been sent are emitted inside the event stream rather than as a new HTTP response.
This flow shows how a Select request moves from object authorization to query evaluation and event output.
flowchart LR
A[SelectObjectContent request] --> B[Authorize object read]
B --> C[Open object snapshot]
C --> D{Input form}
D -->|Parquet or supported CSV/JSON| E[Duck query service]
D -->|Other CSV/JSON| F[Bounded Select evaluator]
E --> G[Records events]
F --> G
G --> H[Stats and End events]
References: src/…/S3Controller.java• L1674-1683 src/…/S3Service.java• L1864-1888
S3 Control behavior
The S3 Control API uses REST-XML routes under /v20180820. It separates account-level Block Public Access state from the same setting on each bucket. Account-level state is keyed by x-amz-account-id, which must be a valid 12-digit account ID before state is read or changed.
The configured management account can act on another account. Other cross-account combinations are denied. A blank or malformed account ID is rejected before account-scoped state is read or changed. The API also supports bucket resource tags and an empty access-point listing. Bucket metrics, analytics, inventory, and Intelligent-Tiering remain general S3 bucket state.
Tag routes accept either a regional bucket ARN such as arn:<partition>:s3:<region>:<account>:bucket/<name> or a global bucket ARN such as arn:<partition>:s3:::<name>. The resource ARN is decoded once before parsing. The regional form selects the account and bucket named by the ARN. Unsupported resources such as access-point ARNs return an invalid-request error. Tag operations list, replace, or remove bucket tags; the access-point list returns a successful empty page.
S3 Control tag-bearing operations have a defined IAM request context. The service maps submitted tag pairs to aws:RequestTag/<key> and submitted tag-name lists to aws:TagKeys according to the operation's request shape. This keeps tag policy checks tied to the operation that carries the tags instead of treating every S3 Control request as if it had the same fields.
S3 Control errors use the REST-XML ErrorResponse envelope with request IDs so AWS SDK clients can parse failures as service errors.
References: src/…/S3ControlArnUtils.java• L9-64 src/…/S3ControlController.java• L65-127 src/…/S3ControlController.java• L130-247 src/…/S3ControlController.java• L267-382 src/…/S3ControlTagConditionKeys.java• L15-66 src/…/S3Service.java• L6263-6304 src/…/S3Service.java• L6526-6566
Change checklist
When these files or sections are changed, remember to consider these:
- Keep every bucket and object sub-resource in the controller's verb and query dispatch. Otherwise the shared route can run a different default action.
- Keep the vendored bucket sub-resource table aligned with controller support and IAM operation names. An AWS-defined but unsupported operation must fail safely instead of falling through.
- Keep decoded query parameters and raw query-string presence checks aligned. Split raw queries before decoding names so an encoded
&inside a value does not select a sub-resource. - Keep bucket-list pagination ordering, page limits, continuation-token ownership, and the no-
max-bucketsfull-list behavior aligned between the controller and service. - Keep version-list sorting, key and version markers, deleted-version position records, and the fallback after position eviction aligned. A deleted marker version still represents a pagination position.
- Keep virtual-host rewriting, website host detection, forwarded-host handling, custom-host fallback, raw object-key extraction, slash-only key routing, and SigV4 canonical request inputs aligned.
- Keep S3 Control path detection and non-S3 service host exclusions aligned with virtual-host routing. Do not route another AWS service or S3 Control request to a bucket.
- Keep
S3ObjectKeysraw-path rules aligned with controller key extraction, IAMRequestPathLabelsresource-key construction, and slash-only routing. Preserve leading slashes, encoded separators, and literal plus signs consistently. - Keep S3 resource path labels aligned with the handler's raw key and with IAM's request-resource builder. A router-normalized key must not replace the key used for policy matching.
- Keep the S3 signature filter scope aligned with the resources that use S3 signing rules. Do not apply S3 filters to S3 Control or another AWS service, and do not sign CORS preflight as the follow-up request.
- Keep header SigV4, SigV4A, presigned URL, and presigned POST parsing aligned with their distinct credential placements. SigV4A must retain its region-set requirement and region-less scope.
- Keep the shared canonical request builder aligned between presigned URL creation and validation. Include the same wire path, encoded query, signed headers, authority, and payload marker.
- Keep generated temporary presigned credentials, scoped S3 resource ARNs, retirement, IAM session state, and advertised URL expiry aligned.
- Keep presigned POST credential scope, strict date matching, policy signature, policy expiry, form conditions, region checks, and IAM authorization aligned.
- Keep object metadata, body storage, version records, delete markers, generation stamps, event sequencers, and annotation parents aligned across writes, reads, copies, and deletes.
- Keep delete-marker reads aligned with their two S3 outcomes: an unnamed current marker is a missing key, while a named marker is a method-not-allowed resource with marker headers.
- Keep annotation limits, UTF-8 validation, checksums, parent version resolution, payload storage, and annotation events aligned across put, get, list, and delete operations.
- Keep object snapshots,
Range,If-Range,partNumber, response lengths, content ranges, multipart part counts, and checksum headers aligned for GET and HEAD. - Keep policy, ACL, object-lock, and public-access-block decisions consistent for signed, anonymous, CloudFront, and internal scratch requests.
- Keep scratch bucket creation, internal tags, hidden listing behavior, transfer key patterns, and IAM scratch scopes aligned for each internal transfer type.
- Keep public-policy classification separate from normal policy matching. A public policy with a narrowing condition has different Block Public Access behavior from an unrestricted wildcard statement. Fixed-account
aws:PrincipalArnconditions can narrow a wildcard statement without making it public. - Keep S3 resource-policy ARN partition resolution aligned with bucket lookup. Do not use a fixed
awspartition when the bucket belongs to another partition. - Keep S3 Control regional bucket ARN parsing aligned between tag handling, IAM resource construction, and account-scoped bucket lookup. Decode a resource ARN once only.
- Keep S3 Control operation metadata aligned with the
aws:RequestTag/<key>andaws:TagKeyscontext values extracted from each request shape. - Keep the four Block Public Access flags aligned with their different write-time and authorization-time effects. Combine bucket and account settings per flag.
- Keep ACL public-group detection aligned with ownership controls and Block Public Access write checks.
- Keep CORS preflight evaluation separate from actual-response header injection and from signature verification.
- Keep AWS chunked framing, decoded body reads, content length handling, minimum non-final chunk size, declared trailer checksums, and undeclared checksum errors aligned for streamed uploads.
- Keep supported checksum algorithms and their allowed multipart checksum types aligned between initiation, part writes, completion, object metadata, and response headers.
- Keep multipart upload settings, owner and initiator accounts, replacement parts, upload locks, checksum declarations, ordered parts, and object-attribute output aligned across initiation, upload, completion, and reads.
- Keep Select input detection, evaluator support, Duck query support, output serialization, record limits, and event-stream error behavior aligned.
- Keep lifecycle XML storage, rule parsing, filters, age calculation, expiration headers, asynchronous sweep timing, and object-lock protection aligned with normal delete semantics.
- Keep account ID validation, caller-account checks, and account-partitioned S3 Control state aligned.
- Keep vector bucket and index name-or-ARN addressing aligned with partition, region, and account checks. An index ARN must resolve the index named by that ARN rather than its bucket's tags.
- Keep vector bucket and index tag validation, create and replace behavior, shared REST tag dispatch, merge and remove semantics, 50-tag limits, and strict payload handling aligned.
- Keep vector bucket and index tags aligned with IAM resource-tag context after tag replacement or shared tag updates. Resource tags must be read from the account and region named by the resource ARN.
- Keep object event names, requester identity, sequencers, and downstream SQS, SNS, Lambda, EventBridge, and CloudTrail consumers aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A sub-resource is missing from verb and query dispatch | A request can fall through to bucket creation, deletion, listing, or another default action | Use the generated sub-resource table and add an explicit controller branch or safe rejection |
| A generated route model is missing or malformed | Bucket requests cannot safely distinguish sub-resources from base bucket operations | Fail during sub-resource table loading rather than using an empty table |
| A bucket-list continuation token is accepted without its account scope | One account can read another account's page position or receive the wrong page | Issue and validate tokens with the owning account scope |
A request without max-buckets keeps the normal page cap | Clients that read one response lose buckets after the cap | Preserve the full-list behavior when the limit is absent |
Raw query parsing decodes before it splits on & | An encoded separator inside a policy, tag, or signed value can select the wrong sub-resource | Split the raw query on literal separators, then decode only the candidate name |
| Raw path extraction uses the normalized framework path | A key with a leading slash, repeated separator, encoded separator, or literal plus can address a different object than the signed request names | Derive the key from the raw request path and use the same value for authorization |
| IAM resource labels use the normalized key while S3 storage uses the raw key | A policy can allow or deny a different object than the request changes | Overlay the service's raw path labels before building the IAM resource ARN |
| A slash-only object key is treated as a bucket request | PUT /bucket// or a similar request can create, list, or delete the bucket instead of changing the object | Rewrite slash-only keys before route matching and keep the key in the IAM check |
| Virtual-host rewriting treats S3 Control or another AWS service as a bucket | A request reaches the wrong service or changes the wrong resource | Exclude /v20180820/, foreign service hosts, and non-S3 signed scopes before rewriting |
| The URL generator and validator build different canonical requests | A URL fails even though the visible method, key, and expiry look correct | Use the shared canonical method and preserve the wire path and encoded query |
| A generated URL's temporary session is not registered or expires early | The URL fails IAM authorization before its advertised expiry | Register a resource-scoped session and retain it for the signed lifetime |
| A presigned POST has a valid-looking form but its policy, date, region, or IAM check is skipped | A browser can write outside the intended principal or form scope | Verify the form signature and policy, then run normal S3 object authorization |
| A presigned URL carries a checksum or user-metadata header that is not signed | S3 rejects the request with AccessDenied even when the URL signature itself matches | Require every supported checksum and x-amz-meta-* header to be signed |
| Object metadata and body state use different generations | GET or Select can return headers and bytes for different object state | Publish body state before metadata and open one read snapshot |
| A current delete marker is exposed as a normal object or a named marker is treated as a missing key | Clients receive the wrong status and cannot distinguish a deleted key from a named delete-marker resource | Resolve marker state before reads and preserve the named-marker response data |
| A version-id-marker names a version deleted after the previous page and its position is ignored | Version listing repeats entries or skips the remaining versions for that key | Retain a bounded deleted-version position and apply the same sort order when resuming |
| A public policy is classified or applied without its conditions | Block Public Access can allow or reject access at the wrong boundary | Keep public-policy classification and principal condition matching separate |
| A public policy allows an action while ACL or public-access-block state is reviewed alone | Anonymous access can remain open through another access layer | Evaluate policy, ACL, and bucket-plus-account public-access settings together |
BlockPublicAcls or BlockPublicPolicy is checked only during authorization | A public ACL or policy can be stored even though the setting must reject the write | Apply write-time checks to ACL and policy updates and object uploads |
| An internal bucket already exists without its expected tag | A transfer can use another bucket or overwrite a user's resource | Require the internal tag before accepting an existing scratch bucket |
| A scratch credential is given a bucket-wide or wrong-prefix resource | An internal transfer can read or change data outside its temporary scope | Match the transfer action, ARN pattern, and list prefix to the registered scratch scope |
| AWS chunked framing ends early or has invalid chunk boundaries | The upload fails with IncompleteBody instead of storing a partial body | Decode the stream while reading and require each chunk terminator and final trailer block |
| A declared Content-MD5 or checksum does not match the streamed body | S3 returns BadDigest and does not publish the object or part | Hash the bytes that pass through the upload stream and verify all claimed values before publication |
| Multipart completion uses a different checksum type, omits a required part checksum, or names parts out of order | Completion returns a part or checksum error and does not publish the object | Carry checksum declarations and ordered part records from initiation through completion |
| Multipart state is read by an account other than the owner or initiator's permitted account | A caller can list, complete, or abort an upload from another account partition | Store owner and initiator account IDs and check them on each multipart operation |
| A lifecycle worker is disabled or its interval is misunderstood as request-time enforcement | Due objects remain until a later sweep | Treat lifecycle as asynchronous and check the effective sweep setting and interval |
| An account control request uses a missing, malformed, or unauthorized account ID | S3 Control returns an invalid-request or access-denied error and leaves state unchanged | Validate the account shape and caller authority before storage access |
| A S3 Control tag ARN is decoded more than once or treats an access point as a bucket | The handler can target the wrong name or accept a resource outside the supported API | Decode once, accept only the supported bucket ARN forms, and derive account and bucket from the parsed ARN |
| A vector request supplies both name and ARN forms, or an ARN names another region or partition | S3 Vectors rejects the request instead of reaching the intended bucket or index | Require exactly one supported address form and validate its request scope |
| A vector tag request uses an invalid key, value, count, or trailing payload | The tag update is rejected instead of changing the resource, or a loose shared parser can hide malformed input | Keep strict shared-handler parsing and service-side tag validation with the 50-tag limit |
| IAM reads tags from a vector bucket when the ARN names an index | A resource-tag condition can allow or deny the wrong vector resource | Match the full ARN and return the bucket or index's own replaced tag map |
Key files
| File | Why to read it |
|---|---|
| src/…/S3Controller.java | Main REST-XML routes, bucket-list pagination, sub-resource dispatch, conditional and ranged reads, uploads, copies, website responses, Select requests, CORS preflight, delete-marker responses, and presigned POST handling |
| src/…/S3BucketSubresources.java | AWS-model-derived bucket sub-resource names and safe handling of defined but unsupported operations |
| src/…/S3QueryParams.java | Shared handling for decoded query parameters and raw flag-only query presence during sub-resource dispatch |
| src/…/S3RequestParser.java | Exact query-name detection after raw query splitting and name decoding |
| src/…/S3Service.java | Bucket and object state, storage, versioning, authorization, lifecycle expiration, multipart, checksums, annotations, account controls, global bucket resolution, scratch buckets, version-list pagination, and events |
| src/…/S3ScratchSpace.java | Internal scratch bucket ownership, transfer key patterns, and narrow IAM resource scopes |
| src/…/S3RequestPathLabels.java | S3-specific raw object-key labels used to keep IAM resource checks aligned with the object path and storage operation |