From 160c45bf2d7f5b6895bea218135c083ddcfca1f3 Mon Sep 17 00:00:00 2001
From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
Date: Sun, 15 Nov 2026 17:45:24 -0400
Subject: [PATCH] fix(s3tables): give resource-tag conditions the tags of the
bucket or table a request names (#8505)
The generated request resources give S3 Tables' TableBucket and Table types
aws:ResourceTag/ keys, but S3TablesStoredResourceArns did not answer
storedTags, so a condition on a table bucket's or a table's tags saw none.
S3TablesService.storedTags now reads the one bucket entry in the account and
Region the ARN names and gives the bucket's tags, or a table's, matched on
the whole ARN, reading only, a bucket stored before storage was account-aware
read in place for the default account, as Secrets Manager's lookup reads one;
S3TablesStoredResourceArns answers it.
---
docs/services/iam.md | 4 +-
.../aws/core/common/StoredResourceArns.java | 7 ++--
.../services/s3tables/S3TablesService.java | 42 +++++++++++++++++++
.../s3tables/S3TablesStoredResourceArns.java | 11 ++++-
.../s3tables/S3TablesIamIntegrationTest.java | 27 ++++++++++++
.../s3tables/S3TablesServiceTest.java | 42 +++++++++++++++++++
6 files changed, 126 insertions(+), 7 deletions(-)
diff --git a/docs/services/iam.md b/docs/services/iam.md
index 69e55251ab..b02e1c60eb 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -3071,8 +3071,8 @@ floci populates:
its type (`aws:ResourceTag/`, `secretsmanager:ResourceTag/`), which `regen_iam_request_resources.py`
reads from the Service Reference for every namespace it reads, valued from the tags the type's service
holds on that resource (`StoredResourceArns.storedTags`); a service that holds none leaves them absent.
- Secrets Manager answers for its secrets. Tag keys differing only in case are one condition key holding
- every value.
+ Secrets Manager answers for its secrets, and S3 Tables for its table buckets and tables. Tag keys differing
+ only in case are one condition key holding every value.
- EC2 resource keys such as a network interface's `ec2:Vpc`, `ec2:Subnet`, `ec2:AvailabilityZone` and
`ec2:NetworkInterfaceID`: for every action on a resource EC2 holds, the members of the resource the
key names, an ARN for a key the Service Reference types as one. `resourceKeys` in
diff --git a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
index 44f1670e94..5978e5f7fd 100644
--- a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
+++ b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
@@ -26,9 +26,10 @@ import java.util.Optional;
* permission sets are provisioned to; Resource Explorer, for its default view; OAM and RAM, for the sinks,
* invitations and shares of other accounts they act on; Secrets Manager, for the secret a name or an ARN names,
* random suffix included, and its tags; EventBridge Scheduler, for its default schedule group; CloudFormation, for
- * the stack or the stack set a name names, whose id it minted); looked up lazily by {@code ResourceArnBuilder} and
- * {@code IamConditionContextResolver} through {@code Instance} for the namespace a request or an
- * ARN is of, so IAM never depends on that service directly.
+ * the stack or the stack set a name names, whose id it minted; S3 Tables, for the table a request names by its table
+ * bucket, namespace and name, and the tags of a table bucket or a table); looked up lazily by
+ * {@code ResourceArnBuilder} and {@code IamConditionContextResolver} through {@code Instance} for
+ * the namespace a request or an ARN is of, so IAM never depends on that service directly.
*
* Each answer is a lookup of what the service holds, asked for by an entry of the generated table ({@code find},
* {@code through}, a default, {@code forwarded}, a type's {@code resourceTagKeys}): never a fact about what an operation acts on, which the table alone
diff --git a/src/main/java/io/floci/aws/services/s3tables/S3TablesService.java b/src/main/java/io/floci/aws/services/s3tables/S3TablesService.java
index 1a825f5f99..845f72a445 100644
--- a/src/main/java/io/floci/aws/services/s3tables/S3TablesService.java
+++ b/src/main/java/io/floci/aws/services/s3tables/S3TablesService.java
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
+import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.StorageBackend;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.s3.S3Service;
@@ -187,6 +188,40 @@ public class S3TablesService {
}
}
+ /**
+ * The tags of the table bucket or the table stored under {@code arn}, in the account and Region the ARN names, by
+ * key, which IAM gives a resource-tag condition; empty when there is none. Reads that one bucket's entry, a
+ * pre-multi-account one of the default account in place, and matches the bucket, or a table of it, on the whole
+ * ARN, leaving both as they are.
+ */
+ public synchronized Map storedTags(String arn) {
+ if (!AwsArnUtils.isArnFor(arn, "s3tables")) {
+ return Map.of();
+ }
+ AwsArnUtils.Arn parsed = AwsArnUtils.parse(arn);
+ if (!parsed.resource().startsWith(BUCKET_PREFIX)) {
+ return Map.of();
+ }
+ String rest = parsed.resource().substring(BUCKET_PREFIX.length());
+ String bucketName = rest.contains("/") ? rest.substring(0, rest.indexOf('/')) : rest;
+ TableBucket bucket = stored(parsed.accountId(), storageKey(parsed.region(), bucketName)).orElse(null);
+ if (bucket == null) {
+ return Map.of();
+ }
+ if (arn.equals(bucket.getArn())) {
+ return Map.copyOf(bucket.getTags());
+ }
+ if (!arn.startsWith(bucket.getArn() + TABLE_INFIX)) {
+ return Map.of();
+ }
+ return bucket.getNamespaces().values().stream()
+ .flatMap(namespace -> namespace.getTables().values().stream())
+ .filter(table -> arn.equals(table.getArn()))
+ .findFirst()
+ .