From 15519216c36f4e46897b3155cd5d2617469f8229 Mon Sep 17 00:00:00 2001
From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
Date: Mon, 16 Nov 2026 23:54:23 -0400
Subject: [PATCH] fix(cloudfront): give resource-tag conditions the tags of the
resource a request names (#8700)
The generated request resources give ten CloudFront types the
aws:ResourceTag/ key, but CloudFrontKeyValueStoreService, the
namespace's StoredResourceArns, answered no tags, so a condition on a
CloudFront resource's tags saw none. It now reads the tags CloudFront
holds under the ARN, in place, from the tag store CloudFrontService
writes, where the tag handlers keep them: in the request's account, by
the whole ARN, since CloudFront ARNs name the default account whichever
account owns the resource. DeleteFunction now removes the tags kept
under the function's ARN, its name, and CreateFunction drops any left
there, so a function created again under a deleted one's name starts
with none. CloudFront's tag writes already put a new map in place of
the held one.
---
docs/services/iam.md | 5 +-
.../aws/core/common/StoredResourceArns.java | 7 +-
.../cloudfront/CloudFrontController.java | 4 +-
.../CloudFrontKeyValueStoreService.java | 28 ++++++++
.../cloudfront/CloudFrontService.java | 12 +++-
.../cloudfront/CloudFrontServiceTest.java | 55 ++++++++++++++++
...amRestRouteEnforcementIntegrationTest.java | 65 +++++++++++++++----
7 files changed, 156 insertions(+), 20 deletions(-)
diff --git a/docs/services/iam.md b/docs/services/iam.md
index d8299600bf..8b646cca36 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -3191,8 +3191,9 @@ floci populates:
projects and report groups, Athena for its workgroups and data catalogs, Redshift Serverless for its namespaces,
workgroups and snapshots, DynamoDB for its tables and their indexes (the table's tags), ECR for its
repositories, Redshift for its clusters, snapshots, parameter groups, subnet groups, snapshot copy grants,
- snapshot schedules, event subscriptions and integrations, SSM for its parameters, documents and associations, and
- EMR for its clusters. Tag keys differing only in case are one condition key holding every value.
+ snapshot schedules, event subscriptions and integrations, SSM for its parameters, documents and associations,
+ EMR for its clusters, and CloudFront for every resource it tags, by its ARN. 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 a6e6fc9a53..60b2059d9e 100644
--- a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
+++ b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
@@ -38,9 +38,10 @@ import java.util.Optional;
* for the tags of a table and its indexes; ECR, for the tags of a repository; Redshift, for the key a snapshot records
* and the tags of a cluster, a snapshot, a parameter group, a subnet group, a snapshot copy grant, a snapshot
* schedule, an event subscription or an integration; SSM, for the parameter a legacy ARN names, the document of
- * another account an association runs and the tags of a parameter, a document or an association); 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.
+ * another account an association runs and the tags of a parameter, a document or an association; CloudFront, for the
+ * key value store a name names and the tags of any resource it tags); 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/cloudfront/CloudFrontController.java b/src/main/java/io/floci/aws/services/cloudfront/CloudFrontController.java
index 696487417e..c8b7e0d19d 100644
--- a/src/main/java/io/floci/aws/services/cloudfront/CloudFrontController.java
+++ b/src/main/java/io/floci/aws/services/cloudfront/CloudFrontController.java
@@ -985,7 +985,7 @@ public class CloudFrontController {
appendKeyValueStoreAssociations(xml, fn);
xml.end("FunctionConfig")
.start("FunctionMetadata")
- .elem("FunctionARN", service.arn("function/" + fn.getName()))
+ .elem("FunctionARN", service.functionArn(fn.getName()))
.elem("Stage", fn.getStage())
.elem("CreatedTime", fn.getCreatedTime() != null ? fn.getCreatedTime().toString() : "")
.elem("LastModifiedTime",
@@ -2533,7 +2533,7 @@ public class CloudFrontController {
appendKeyValueStoreAssociations(xml, fn);
return xml.end("FunctionConfig")
.start("FunctionMetadata")
- .elem("FunctionARN", service.arn("function/" + fn.getName()))
+ .elem("FunctionARN", service.functionArn(fn.getName()))
.elem("Stage", fn.getStage())
.elem("CreatedTime", fn.getCreatedTime() != null ? fn.getCreatedTime().toString() : "")
.elem("LastModifiedTime",
diff --git a/src/main/java/io/floci/aws/services/cloudfront/CloudFrontKeyValueStoreService.java b/src/main/java/io/floci/aws/services/cloudfront/CloudFrontKeyValueStoreService.java
index 84d63e168b..b3ee02cccd 100644
--- a/src/main/java/io/floci/aws/services/cloudfront/CloudFrontKeyValueStoreService.java
+++ b/src/main/java/io/floci/aws/services/cloudfront/CloudFrontKeyValueStoreService.java
@@ -1,6 +1,7 @@
package io.floci.aws.services.cloudfront;
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.PaginatedResult;
import io.floci.aws.core.common.Pagination;
@@ -49,12 +50,19 @@ public class CloudFrontKeyValueStoreService implements StoredResourceArns {
private static final String STATUS_READY = "READY";
private final StorageBackend store;
+ /**
+ * The tags CloudFront holds by resource ARN, which {@link CloudFrontService} keeps; the factory hands every caller
+ * of the file the same store, so this one reads the tags it writes.
+ */
+ private final StorageBackend> tags;
private final RegionResolver regionResolver;
@Inject
public CloudFrontKeyValueStoreService(StorageFactory factory, RegionResolver regionResolver) {
this.store = factory.create("cloudfront", "cloudfront-key-value-stores.json",
new TypeReference