From 422c78866d14647ecb9d694e16804c4326bde4d3 Mon Sep 17 00:00:00 2001
From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
Date: Mon, 23 Nov 2026 17:28:33 -0400
Subject: [PATCH] feat(iam): read AWS Config from the generated tables (#9296)
Move `config` from NOT_COVERED to NAMESPACES in
regen_iam_request_resources.py, so Config requests are checked on the
resources they name instead of `*`. A config rule's, configuration
recorder's and conformance pack's ARN ends in an id Config mints, which a
request naming one by its name does not carry, so ConfigStoredResourceArns
answers the table's lookups with the ARN Config stores it under; one Config
holds none of is checked on its name with the id open. The tag calls are
read from ResourceArn.
Two generic readings are added to the generator, changing Config's
PutAggregationAuthorization and PutConfigurationRecorder rows and no other
operation's: a format naming an account or a Region of its own beside the
ARN's takes them from the request's one account id member and its one
Region member, and a member filling one of the format's variables is no
longer also the ARN's account; and a type the request names but fills no
variable of takes its one name variable from the request's structure named
after the type (ConfigurationRecorder.name).
PutConfigRule now updates the rule its ConfigRuleArn names, else its
ConfigRuleId, else its ConfigRuleName, as the PutConfigRule reference lets
an update name its rule by any of the three, and refuses an ARN or id that
names no rule with InvalidParameterValueException. Finding the rule by name
alone let a request carrying one rule's id and another rule's name be
checked on the first and change the second.
---
docs/services/config.md | 24 ++++
docs/services/iam.md | 2 +-
.../aws/core/common/StoredResourceArns.java | 3 +-
.../configservice/AwsConfigService.java | 43 +++++-
.../ConfigStoredResourceArns.java | 37 +++++
.../resources/aws/iam-request-resources.json | 110 ++++++++++++++-
.../AwsConfigServicePutConfigRuleTest.java | 59 ++++++++
.../configservice/ConfigFixtures.java | 33 +++++
.../ConfigStoredResourceArnsTest.java | 42 ++++++
...estResourceEnforcementIntegrationTest.java | 129 ++++++++++++++++++
.../services/iam/ResourceArnBuilderTest.java | 44 ++++++
tools/aws/regen_iam_request_resources.py | 81 ++++++++++-
tools/aws/test_regen_iam_request_resources.py | 51 +++++++
13 files changed, 648 insertions(+), 10 deletions(-)
create mode 100644 src/main/java/io/floci/aws/services/configservice/ConfigStoredResourceArns.java
create mode 100644 src/test/java/io/floci/aws/services/configservice/AwsConfigServicePutConfigRuleTest.java
create mode 100644 src/test/java/io/floci/aws/services/configservice/ConfigFixtures.java
create mode 100644 src/test/java/io/floci/aws/services/configservice/ConfigStoredResourceArnsTest.java
diff --git a/docs/services/config.md b/docs/services/config.md
index 0e038662f7..c178132ef7 100644
--- a/docs/services/config.md
+++ b/docs/services/config.md
@@ -87,6 +87,26 @@ An omitted or empty list selects all recorders; one unknown name returns
| `UntagResource` | Remove tags from a Config resource |
| `ListTagsForResource` | List tags on a Config resource |
+## IAM enforcement
+
+With IAM enforcement on, each action is checked on the resources the AWS Service Authorization
+Reference lists for it, read from the request. A config rule, a configuration recorder and a
+conformance pack carry an id Config mints in their ARNs (`config-rule/`,
+`configuration-recorder//`, `conformance-pack//`), so a request naming one by
+its name is checked on the ARN Config stores it under. One Config holds none of is checked on its
+name with the id open (`conformance-pack//*`), or on `config-rule/*` for a rule. The tag
+calls are checked on their `ResourceArn`.
+
+A `PutConfigRule` is checked on the rule its `ConfigRuleArn` or `ConfigRuleId` names, which is the
+rule it updates (below), and on `*` when it names neither, as a new rule does and an update by
+`ConfigRuleName` alone does. `PutConfigurationRecorder` is checked on the recorder its
+`ConfigurationRecorder` structure's `name` names, the ARN Config stores it under, or
+`configuration-recorder//*` for a new one. `PutAggregationAuthorization` is checked on
+`arn:aws:config:::aggregation-authorization//`,
+in the caller's account, the ARN Config gives the authorization. `DeleteAggregationAuthorization`,
+`StartConfigRulesEvaluation`, the delivery channel and retention calls and the Describe and
+compliance summaries that name no single rule are checked on `*`.
+
## Configuration
| Variable | Default | Description |
@@ -205,6 +225,10 @@ aws configservice delete-config-rule --config-rule-name s3-bucket-versioning
authorization or configuration recorder ARN that does not name an existing resource in the
caller's account and region. ARNs of resource kinds Floci does not model (configuration
aggregators, stored queries, organization rules and packs) are accepted without an existence check.
+ - `PutConfigRule` updates the rule its `ConfigRuleArn` names, else the one its `ConfigRuleId`
+ names, else the one its `ConfigRuleName` names, as the PutConfigRule reference lets an update
+ name its rule by any of the three; a rule named by its ARN or id keeps its name. An ARN or id
+ that names no rule answers `InvalidParameterValueException`, in Floci's wording.
- `PutConfigRule` applies its `Tags` only when it creates the rule; a later
`PutConfigRule` for the same rule leaves its tags unchanged, as AWS documents. Use
`TagResource` and `UntagResource` to change them. `DeleteConfigRule` drops the rule's tags.
diff --git a/docs/services/iam.md b/docs/services/iam.md
index 7503933ae3..d3908ac4d9 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -2542,7 +2542,7 @@ AWS Data Exports, AWS Pricing Calculator, Cost Explorer, CloudTrail, Global Acce
Timestream for InfluxDB, Amazon Redshift, the Amazon Redshift Data API, AWS Payment Cryptography, AWS DataSync, Amazon EMR,
Amazon Rekognition, IAM Identity Center, Amazon Inspector, Amazon Macie, AWS Fault Injection Service, AWS Resource
Access Manager, CloudWatch Observability Access Manager, AWS Resource Explorer, AWS Account Management, AWS Control
-Catalog, Amazon OpenSearch Service, IAM Access Analyzer, AWS Security Hub, Amazon GuardDuty, Lambda, AWS Glue, Amazon SQS, Amazon SNS, Amazon Kinesis Data Streams, Amazon EventBridge Pipes, Aurora DSQL, STS, Amazon EKS, AWS Resource Groups, Amazon CloudWatch Logs, Amazon CloudWatch and Amazon Comprehend they come from a table generated from AWS's Service Reference and botocore, `src/main/resources/aws/iam-request-resources.json`, which gives each
+Catalog, Amazon OpenSearch Service, IAM Access Analyzer, AWS Security Hub, Amazon GuardDuty, Lambda, AWS Glue, Amazon SQS, Amazon SNS, Amazon Kinesis Data Streams, Amazon EventBridge Pipes, Aurora DSQL, STS, Amazon EKS, AWS Resource Groups, Amazon CloudWatch Logs, Amazon CloudWatch, Amazon Comprehend and AWS Config they come from a table generated from AWS's Service Reference and botocore, `src/main/resources/aws/iam-request-resources.json`, which gives each
operation's action, the resource types that action acts on with their ARN formats, and the request
members that name them: a member holding a resource's ARN, which counts when it matches the format
of a type the action acts on, or members filling the variables of a type's format. Nothing in it is
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 46b98ee77c..a8a6360a87 100644
--- a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
+++ b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
@@ -69,7 +69,8 @@ import java.util.Optional;
* association or an access entry; Resource Groups, for the tags of a group; CloudWatch Logs, for a delivery, the
* delivery destinations of a delivery source and the tags of a log group, a destination, a delivery source, a
* delivery destination or a delivery; Pricing Calculator, for the tags of a workload estimate; Amazon Managed Service
- * for Prometheus, for the tags of a workspace or a rule groups namespace); looked up lazily by
+ * for Prometheus, for the tags of a workspace or a rule groups namespace; AWS Config, for the config rule,
+ * configuration recorder or conformance pack 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.
*
diff --git a/src/main/java/io/floci/aws/services/configservice/AwsConfigService.java b/src/main/java/io/floci/aws/services/configservice/AwsConfigService.java
index 8f682e0477..da411cce21 100644
--- a/src/main/java/io/floci/aws/services/configservice/AwsConfigService.java
+++ b/src/main/java/io/floci/aws/services/configservice/AwsConfigService.java
@@ -37,6 +37,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BooleanSupplier;
@@ -177,7 +178,7 @@ public class AwsConfigService {
* the tags alone, which TagResource/UntagResource change instead. The get-then-put runs under
* the lock delete takes, so a delete cannot land between them and orphan the creation tags. */
public ConfigRule putConfigRule(String region, ConfigRule requested, List