diff --git a/compatibility-tests/sdk-test-awscli/test/s3.bats b/compatibility-tests/sdk-test-awscli/test/s3.bats
index 3d70832af2..50914ebe78 100644
--- a/compatibility-tests/sdk-test-awscli/test/s3.bats
+++ b/compatibility-tests/sdk-test-awscli/test/s3.bats
@@ -339,3 +339,58 @@ EOF
assert_failure
assert_output --partial "NoSuchConfiguration"
}
+
+@test "S3: intelligent-tiering configurations round-trip and never touch the bucket" {
+ aws_cmd s3api create-bucket --bucket "$BUCKET" >/dev/null
+
+ run aws_cmd s3api put-bucket-intelligent-tiering-configuration \
+ --bucket "$BUCKET" --id EntireBucket \
+ --intelligent-tiering-configuration 'Id=EntireBucket,Status=Enabled,Tierings=[{AccessTier=ARCHIVE_ACCESS,Days=90}]'
+ assert_success
+
+ run aws_cmd s3api get-bucket-intelligent-tiering-configuration --bucket "$BUCKET" --id EntireBucket
+ assert_success
+ [ "$(json_get "$output" '.IntelligentTieringConfiguration.Id')" = "EntireBucket" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfiguration.Status')" = "Enabled" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfiguration.Tierings[0].AccessTier')" = "ARCHIVE_ACCESS" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfiguration.Tierings[0].Days')" = "90" ]
+
+ run aws_cmd s3api put-bucket-intelligent-tiering-configuration \
+ --bucket "$BUCKET" --id Filtered \
+ --intelligent-tiering-configuration 'Id=Filtered,Filter={And={Prefix=logs/,Tags=[{Key=env,Value=prod}]}},Status=Disabled,Tierings=[{AccessTier=ARCHIVE_ACCESS,Days=90},{AccessTier=DEEP_ARCHIVE_ACCESS,Days=180}]'
+ assert_success
+
+ run aws_cmd s3api list-bucket-intelligent-tiering-configurations --bucket "$BUCKET"
+ assert_success
+ [ "$(json_get "$output" '.IntelligentTieringConfigurationList | length')" = "2" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfigurationList[1].Filter.And.Prefix')" = "logs/" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfigurationList[1].Filter.And.Tags[0].Key')" = "env" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfigurationList[1].Status')" = "Disabled" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfigurationList[1].Tierings | length')" = "2" ]
+
+ # Putting the same id replaces rather than duplicates.
+ run aws_cmd s3api put-bucket-intelligent-tiering-configuration \
+ --bucket "$BUCKET" --id EntireBucket \
+ --intelligent-tiering-configuration 'Id=EntireBucket,Status=Disabled,Tierings=[{AccessTier=DEEP_ARCHIVE_ACCESS,Days=180}]'
+ assert_success
+
+ run aws_cmd s3api get-bucket-intelligent-tiering-configuration --bucket "$BUCKET" --id EntireBucket
+ assert_success
+ [ "$(json_get "$output" '.IntelligentTieringConfiguration.Status')" = "Disabled" ]
+ [ "$(json_get "$output" '.IntelligentTieringConfiguration.Tierings[0].AccessTier')" = "DEEP_ARCHIVE_ACCESS" ]
+
+ run aws_cmd s3api list-bucket-intelligent-tiering-configurations --bucket "$BUCKET"
+ assert_success
+ [ "$(json_get "$output" '.IntelligentTieringConfigurationList | length')" = "2" ]
+
+ # A sub-resource DELETE removes only that configuration; the bucket must survive it.
+ run aws_cmd s3api delete-bucket-intelligent-tiering-configuration --bucket "$BUCKET" --id EntireBucket
+ assert_success
+
+ run aws_cmd s3api head-bucket --bucket "$BUCKET"
+ assert_success
+
+ run aws_cmd s3api get-bucket-intelligent-tiering-configuration --bucket "$BUCKET" --id EntireBucket
+ assert_failure
+ assert_output --partial "NoSuchConfiguration"
+}
diff --git a/docs/services/s3.md b/docs/services/s3.md
index 1f508587c0..6d7a7553ff 100644
--- a/docs/services/s3.md
+++ b/docs/services/s3.md
@@ -25,6 +25,7 @@
| **S3 Select** | SelectObjectContent |
| **Public Access Block** | PutPublicAccessBlock, GetPublicAccessBlock, DeletePublicAccessBlock |
| **Metrics** | PutBucketMetricsConfiguration, GetBucketMetricsConfiguration, ListBucketMetricsConfigurations, DeleteBucketMetricsConfiguration |
+| **Intelligent-Tiering** | PutBucketIntelligentTieringConfiguration, GetBucketIntelligentTieringConfiguration, ListBucketIntelligentTieringConfigurations, DeleteBucketIntelligentTieringConfiguration |
| **Replication** | PutBucketReplication, GetBucketReplication, DeleteBucketReplication |
**RestoreObject** is accepted but stubbed: Floci validates the request and returns `202 Accepted`, but no restore state machine runs.
@@ -173,7 +174,6 @@ These AWS S3 features have no handler in Floci. Calls will return an error (typi
- Access logging (`PutBucketLogging`, `GetBucketLogging`)
- Request payment (`PutBucketRequestPayment`, `GetBucketRequestPayment`)
-- Intelligent-Tiering configurations
- Inventory configurations
- Analytics configurations
@@ -262,9 +262,11 @@ Enable it in the SDK with `forcePathStyle` / `pathStyleAccessEnabled`:
=== "Python"
```python
- s3 = boto3.client("s3",
+ s3 = boto3.client(
+ "s3",
endpoint_url="http://localhost:4566",
- config=Config(s3={"addressing_style": "path"}))
+ config=Config(s3={"addressing_style": "path"}),
+ )
```
### Virtual-Hosted Style
@@ -313,8 +315,7 @@ Configure the SDK endpoint to one of the base domains (no `forcePathStyle`):
=== "Python"
```python
- s3 = boto3.client("s3",
- endpoint_url="http://s3.localhost.floci.io:4566")
+ s3 = boto3.client("s3", endpoint_url="http://s3.localhost.floci.io:4566")
# SDK sends requests to: my-bucket.s3.localhost.floci.io:4566
```
diff --git a/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java b/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java
index d58475d666..928a9e0105 100644
--- a/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java
+++ b/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java
@@ -332,6 +332,14 @@ public class S3Controller {
if (hasQueryParam(uriInfo, "metrics")) {
return handlePutBucketMetricsConfiguration(bucket, uriInfo, body);
}
+ // Same fall-through hazard as metrics: an intelligent-tiering PUT must not become a
+ // CreateBucket.
+ if (hasQueryParam(uriInfo, "intelligent-tiering")) {
+ S3Service.RequestAuthorization authorization = S3RequestAuthorizationParser.parseIfRequired(
+ s3Service.isAuthEnforced(), httpHeaders, uriInfo);
+ s3Service.authorizeBucketWrite(bucket, "s3:PutIntelligentTieringConfiguration", authorization);
+ return handlePutBucketIntelligentTieringConfiguration(bucket, uriInfo, body);
+ }
String locationConstraint = null;
if (body != null && body.length > 0) {
@@ -374,7 +382,8 @@ public class S3Controller {
@DELETE
@Path("/{bucket}")
public Response deleteBucket(@PathParam("bucket") String bucket,
- @Context UriInfo uriInfo) {
+ @Context UriInfo uriInfo,
+ @Context HttpHeaders httpHeaders) {
try {
validateRawUri();
if (hasQueryParam(uriInfo, "tagging")) {
@@ -418,6 +427,15 @@ public class S3Controller {
s3Service.deleteBucketMetricsConfiguration(bucket, requireMetricsId(uriInfo));
return Response.noContent().build();
}
+ if (hasQueryParam(uriInfo, "intelligent-tiering")) {
+ // Likewise this must not fall through to deleting the bucket.
+ S3Service.RequestAuthorization authorization = S3RequestAuthorizationParser.parseIfRequired(
+ s3Service.isAuthEnforced(), httpHeaders, uriInfo);
+ s3Service.authorizeBucketWrite(bucket, "s3:PutIntelligentTieringConfiguration", authorization);
+ s3Service.deleteBucketIntelligentTieringConfiguration(bucket,
+ requireIntelligentTieringId(uriInfo));
+ return Response.noContent().build();
+ }
if (hasQueryParam(uriInfo, "accelerate")) {
// AWS defines no DELETE for the accelerate subresource; reject it here so
// it does NOT fall through to deleting the whole bucket.
@@ -543,6 +561,17 @@ public class S3Controller {
: s3Service.listBucketMetricsConfigurations(bucket);
return Response.ok(xml).type("application/xml").build();
}
+ // GetBucketIntelligentTieringConfiguration and ListBucketIntelligentTieringConfigurations
+ // share ?intelligent-tiering and are told apart by the id, which only the
+ // single-configuration read carries.
+ if (hasQueryParam(uriInfo, "intelligent-tiering")) {
+ s3Service.authorizeBucketRead(bucket, "s3:GetIntelligentTieringConfiguration", authorization);
+ String id = uriInfo.getQueryParameters().getFirst("id");
+ String xml = id != null
+ ? s3Service.getBucketIntelligentTieringConfiguration(bucket, id)
+ : s3Service.listBucketIntelligentTieringConfigurations(bucket);
+ return Response.ok(xml).type("application/xml").build();
+ }
// --- S3 static-website index resolution (site root) ---
// A website endpoint has no S3 REST API, so it serves the index document for the site root
@@ -1839,6 +1868,37 @@ public class S3Controller {
return id;
}
+ // --- Intelligent-Tiering Configurations ---
+
+ private Response handlePutBucketIntelligentTieringConfiguration(String bucket, UriInfo uriInfo,
+ byte[] body) {
+ String id = requireIntelligentTieringId(uriInfo);
+ String xml = body == null ? null : new String(body, StandardCharsets.UTF_8);
+ S3IntelligentTieringConfiguration configuration =
+ S3IntelligentTieringConfiguration.parse(xml);
+ // AWS rejects a body whose Id disagrees with the id in the query string.
+ if (!id.equals(configuration.id())) {
+ throw new AwsException("MalformedXML",
+ "The XML you provided was not well-formed or did not validate against our "
+ + "published schema", 400);
+ }
+ s3Service.putBucketIntelligentTieringConfiguration(bucket, id, configuration.innerXml());
+ return Response.noContent().build();
+ }
+
+ /**
+ * The id identifies the configuration, so a request without one is refused rather than guessed
+ * at, mirroring the metrics subresource.
+ */
+ private String requireIntelligentTieringId(UriInfo uriInfo) {
+ String id = uriInfo.getQueryParameters().getFirst("id");
+ if (id == null) {
+ throw new AwsException("InvalidArgument",
+ "The intelligent-tiering configuration id must be specified.", 400);
+ }
+ return id;
+ }
+
// --- Object Tagging ---
private Response handlePutObjectTagging(String bucket, String key, byte[] body) {
@@ -2486,6 +2546,18 @@ public class S3Controller {
if (condition != null) {
xmlBuilder.elem("Condition", condition);
}
+ // S3 InvalidArgument responses carry ArgumentName and ArgumentValue so the SDK can
+ // surface which input was rejected. They travel through AwsException.extendedData.
+ if (e.getExtendedData() != null) {
+ Object argumentName = e.getExtendedData().get("ArgumentName");
+ Object argumentValue = e.getExtendedData().get("ArgumentValue");
+ if (argumentName != null) {
+ xmlBuilder.elem("ArgumentName", argumentName.toString());
+ }
+ if (argumentValue != null) {
+ xmlBuilder.elem("ArgumentValue", argumentValue.toString());
+ }
+ }
String xml = xmlBuilder
.elem("RequestId", java.util.UUID.randomUUID().toString())
.end("Error")
diff --git a/src/main/java/io/github/hectorvent/floci/services/s3/S3IntelligentTieringConfiguration.java b/src/main/java/io/github/hectorvent/floci/services/s3/S3IntelligentTieringConfiguration.java
new file mode 100644
index 0000000000..5e1d3b2416
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/s3/S3IntelligentTieringConfiguration.java
@@ -0,0 +1,200 @@
+package io.github.hectorvent.floci.services.s3;
+
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.XmlBuilder;
+import io.github.hectorvent.floci.core.common.XmlParser;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A parsed {@code IntelligentTieringConfiguration} request body, reduced to a canonical
+ * serialization of its contents.
+ *
+ *
The body is re-serialized rather than stored verbatim, so that what a later
+ * GetBucketIntelligentTieringConfiguration or ListBucketIntelligentTieringConfigurations returns
+ * is built by floci instead of being whatever XML the caller sent, and so that the same stored
+ * form can be wrapped in either response.
+ */
+record S3IntelligentTieringConfiguration(String id, String innerXml) {
+
+ private static final String ROOT = "IntelligentTieringConfiguration";
+
+ private static final List STATUSES = List.of("Enabled", "Disabled");
+ private static final List ACCESS_TIERS = List.of("ARCHIVE_ACCESS", "DEEP_ARCHIVE_ACCESS");
+
+ private static final int ARCHIVE_ACCESS_MIN_DAYS = 90;
+ private static final int DEEP_ARCHIVE_ACCESS_MIN_DAYS = 180;
+ private static final int MAX_DAYS = 730;
+
+ /** AWS reports a body that does not match the published schema this way. */
+ private static AwsException malformed() {
+ return new AwsException("MalformedXML",
+ "The XML you provided was not well-formed or did not validate against our published schema", 400);
+ }
+
+ /**
+ * AWS reports a {@code Days} value outside the tier-specific allowed range this way: the XML
+ * is well-formed, but the value is semantically invalid. Minimums are tier-specific
+ * ({@link #ARCHIVE_ACCESS_MIN_DAYS} for ARCHIVE_ACCESS, {@link #DEEP_ARCHIVE_ACCESS_MIN_DAYS}
+ * for DEEP_ARCHIVE_ACCESS) and both are capped at {@link #MAX_DAYS}. The response carries
+ * {@code ArgumentName} and {@code ArgumentValue} so the SDK can surface which input was
+ * rejected, matching the real S3 error shape.
+ */
+ private static AwsException daysOutOfRange(String accessTier, int min, int days) {
+ String message = days < min
+ ? "Days must be at least " + min + " for AccessTier " + accessTier + "."
+ : "Days must be at most " + MAX_DAYS + " for AccessTier " + accessTier + ".";
+ Map detail = new LinkedHashMap<>();
+ detail.put("ArgumentName", "Tiering.Days");
+ detail.put("ArgumentValue", String.valueOf(days));
+ return new AwsException("InvalidArgument", message, 400, detail);
+ }
+
+ static S3IntelligentTieringConfiguration parse(String xml) {
+ if (xml == null || xml.isBlank() || !ROOT.equals(XmlParser.rootElementName(xml))) {
+ throw malformed();
+ }
+
+ // The configuration is one Id, one Status, at most one Filter, and at least one Tiering,
+ // so anything else under the root is a body AWS would not have accepted.
+ List children = XmlParser.childElementNames(xml, ROOT);
+ long ids = children.stream().filter("Id"::equals).count();
+ long statuses = children.stream().filter("Status"::equals).count();
+ long filters = children.stream().filter("Filter"::equals).count();
+ long tierings = children.stream().filter("Tiering"::equals).count();
+ if (ids != 1 || statuses != 1 || filters > 1 || tierings < 1
+ || children.size() != ids + statuses + filters + tierings) {
+ throw malformed();
+ }
+
+ String id = XmlParser.extractFirst(xml, "Id", null);
+ if (id == null || id.isBlank()) {
+ throw malformed();
+ }
+
+ String status = XmlParser.extractFirst(xml, "Status", null);
+ if (status == null || !STATUSES.contains(status)) {
+ throw malformed();
+ }
+
+ XmlBuilder inner = new XmlBuilder().elem("Id", id);
+ if (filters == 1) {
+ inner.start("Filter").raw(filterXml(xml)).end("Filter");
+ }
+ inner.elem("Status", status);
+ for (int i = 0; i < tierings; i++) {
+ inner.start("Tiering").raw(tieringXml(xml, i)).end("Tiering");
+ }
+ return new S3IntelligentTieringConfiguration(id, inner.build());
+ }
+
+ /**
+ * Serializes the filter. A filter is exactly one of a prefix, an object tag, or an And
+ * conjunction: AWS answers MalformedXML for a filter naming none of them or more than one,
+ * and for an And holding fewer than two predicates.
+ */
+ private static String filterXml(String xml) {
+ List predicates = XmlParser.childElementNames(xml, "Filter");
+ if (predicates.size() != 1) {
+ throw malformed();
+ }
+
+ String predicate = predicates.getFirst();
+ return switch (predicate) {
+ case "Prefix" -> new XmlBuilder().elem("Prefix", requireText(xml, "Prefix")).build();
+ case "Tag" -> tagsXml(xml, 1);
+ case "And" -> {
+ List conjuncts = XmlParser.childElementNames(xml, "And");
+ if (conjuncts.size() < 2) {
+ throw malformed();
+ }
+ XmlBuilder and = new XmlBuilder().start("And");
+ if (conjuncts.contains("Prefix")) {
+ and.elem("Prefix", requireText(xml, "Prefix"));
+ }
+ long tagCount = conjuncts.stream().filter("Tag"::equals).count();
+ if (tagCount > 0) {
+ and.raw(tagsXml(xml, (int) tagCount));
+ }
+ // Every conjunct has to be one floci understands, or the filter it stores would
+ // not be the filter that was sent.
+ if (conjuncts.size() != tagCount + (conjuncts.contains("Prefix") ? 1 : 0)) {
+ throw malformed();
+ }
+ yield and.end("And").build();
+ }
+ default -> throw malformed();
+ };
+ }
+
+ /**
+ * Serializes {@code expected} tags. A tag carries both a key and a value, so a pair short of
+ * the element count means one of them was missing.
+ */
+ private static String tagsXml(String xml, int expected) {
+ Map tags = XmlParser.extractPairs(xml, "Tag", "Key", "Value");
+ if (tags.size() != expected) {
+ throw malformed();
+ }
+ XmlBuilder out = new XmlBuilder();
+ tags.forEach((key, value) -> {
+ if (key.isBlank() || value == null) {
+ throw malformed();
+ }
+ out.start("Tag").elem("Key", key).elem("Value", value).end("Tag");
+ });
+ return out.build();
+ }
+
+ /**
+ * Serializes the {@code index}-th {@code Tiering} entry. Each tiering is an access tier and a
+ * positive day count, and both are required. Days must also fall in the tier-specific range
+ * AWS enforces: {@link #ARCHIVE_ACCESS_MIN_DAYS}-{@link #MAX_DAYS} for ARCHIVE_ACCESS and
+ * {@link #DEEP_ARCHIVE_ACCESS_MIN_DAYS}-{@link #MAX_DAYS} for DEEP_ARCHIVE_ACCESS.
+ */
+ private static String tieringXml(String xml, int index) {
+ List