From 66eb95661e7cb94cfa5148e3103785dbf2e5dd79 Mon Sep 17 00:00:00 2001
From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
Date: Mon, 16 Nov 2026 21:38:18 -0400
Subject: [PATCH] fix(ssm): give resource-tag conditions the tags of the
resource a request names (#8691)
The generated request resources give SSM's parameter, document and
association types the aws:ResourceTag/ key (and ssm:resourceTag/ for
the first two), but SsmService answered no tags, so a condition on an
SSM resource's tags saw none. SsmService.storedTags now reads the
parameter, document or association stored under the ARN in the account
and Region it names, in place, matched on the whole ARN; a parameter
ARN names / before , as tagging reads it. Tag writes now
put a new map in place of the held one, a parameter's filled one entry
at a time so the listed order holds, and the parameter tag writes the
CloudFormation provisioner calls take the service's lock as the others
do; the tag fields are volatile.
---
docs/services/iam.md | 6 +-
.../aws/core/common/StoredResourceArns.java | 7 +-
.../io/floci/aws/services/ssm/SsmService.java | 89 ++++++++++++++++---
.../aws/services/ssm/model/Parameter.java | 2 +-
.../services/ssm/model/SsmAssociation.java | 2 +-
.../aws/services/ssm/model/SsmDocument.java | 2 +-
...estResourceEnforcementIntegrationTest.java | 62 +++++++++++--
.../aws/services/ssm/SsmServiceTest.java | 48 ++++++++++
8 files changed, 191 insertions(+), 27 deletions(-)
diff --git a/docs/services/iam.md b/docs/services/iam.md
index 90e5f51033..cc4bb9a142 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -3190,9 +3190,9 @@ floci populates:
state machines, their versions and executions (the state machine's tags) and activities, CodeBuild for its
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, and Redshift for its clusters, snapshots, parameter groups, subnet groups, snapshot copy grants,
- snapshot schedules, event subscriptions and integrations. Tag keys differing only in case are one condition key
- holding every value.
+ repositories, Redshift for its clusters, snapshots, parameter groups, subnet groups, snapshot copy grants,
+ snapshot schedules, event subscriptions and integrations, and SSM for its parameters, documents and associations.
+ 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 0ebdd62e1e..062004965c 100644
--- a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
+++ b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
@@ -36,9 +36,10 @@ import java.util.Optional;
* workgroup or a data catalog; Redshift Serverless, for the tags of a namespace, a workgroup or a snapshot; DynamoDB,
* 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); 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.
+ * 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.
*
* 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/ssm/SsmService.java b/src/main/java/io/floci/aws/services/ssm/SsmService.java
index 2b7adb5dfe..b31d2691e6 100644
--- a/src/main/java/io/floci/aws/services/ssm/SsmService.java
+++ b/src/main/java/io/floci/aws/services/ssm/SsmService.java
@@ -59,6 +59,8 @@ public class SsmService implements ResourceProvider, StoredResourceArns {
private static final String PUBLIC_PARAMETER_PREFIX = "/aws/service/";
private static final String DOCUMENT_PREFIX = "document/";
+ private static final String PARAMETER_PREFIX = "parameter/";
+ private static final String ASSOCIATION_PREFIX = "association/";
private static final String ECS_AL2023_RECOMMENDED =
"/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended";
private static final String ECS_AL2023_ARM64_RECOMMENDED =
@@ -1154,8 +1156,9 @@ public class SsmService implements ResourceProvider, StoredResourceArns {
}
/**
- * Applies {@code change} to the tags of the document or association {@code resourceId} names and stores
- * it; {@code false}, changing nothing, for any other {@code resourceType}.
+ * Applies {@code change} to a copy of the tags of the document or association {@code resourceId} names, puts the
+ * copy in place of the held map and stores it; {@code false}, changing nothing, for any other
+ * {@code resourceType}.
*/
private boolean updateTags(String resourceType, String resourceId, String region,
Consumer