From bb8a92b8fd1f95d0b47382852dbaaeb8da00fc4d Mon Sep 17 00:00:00 2001
From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
Date: Wed, 18 Nov 2026 01:43:59 -0400
Subject: [PATCH] fix(budgets): give resource-tag conditions the tags of the
budget or budget action a request names (#8823)
The generated request resources give Budgets' budget and budgetAction
types the aws:ResourceTag/ key, but no service answered the budgets
namespace's stored tags, so a condition on a budget's or an action's
tags saw none. BudgetsService now answers it: a budget records no ARN,
so storedTags takes the ARN only when it is the one the budget's account
and name give in the request's partition, an action's adding its id,
then reads the record under the key the handlers read, in the request's
account, in place. Tag calls already run one at a time and give the
record a new tag list; the tag fields are now volatile.
---
docs/services/iam.md | 4 +-
.../aws/core/common/StoredResourceArns.java | 8 +-
.../aws/services/budgets/BudgetsService.java | 73 +++++++++++++++++--
.../budgets/model/BudgetActionRecord.java | 2 +-
.../services/budgets/model/BudgetRecord.java | 2 +-
.../services/budgets/BudgetsServiceTest.java | 57 ++++++++++++++-
...estResourceEnforcementIntegrationTest.java | 44 +++++++++--
.../resources/partition/smoke-exemptions.tsv | 1 +
8 files changed, 166 insertions(+), 25 deletions(-)
diff --git a/docs/services/iam.md b/docs/services/iam.md
index 7321ba3188..760983b01b 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -3355,8 +3355,8 @@ floci populates:
instances, ACM for its certificates, Firehose for its delivery streams, Cognito for its user pools and identity
pools, OpenSearch for its domains, Signer for its signing profiles, Access Analyzer for its analyzers, Managed Service
for Apache Flink for its applications, S3 Vectors for its vector buckets and indexes, Timestream for InfluxDB for its
- DB instances, DB clusters, parameter groups and backups, and CloudTrail for its trails. Tag keys differing only in
- case are one condition key holding every value.
+ DB instances, DB clusters, parameter groups and backups, CloudTrail for its trails, and Budgets for its budgets and
+ budget actions. 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 63abf34f08..ca23f387d2 100644
--- a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
+++ b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
@@ -48,10 +48,10 @@ import java.util.Optional;
* stream; Cognito, for the tags of a user pool or an identity pool; OpenSearch, for the tags of a domain; Signer, for
* the tags of a signing profile; Access Analyzer, for the tags of an analyzer; Managed Service for Apache Flink, for
* the tags of an application; S3 Vectors, for the tags of a vector bucket or an index; Timestream for InfluxDB, for the
- * tags of a DB instance, a DB cluster, a parameter group or a backup; CloudTrail, for the tags of a trail); 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.
+ * tags of a DB instance, a DB cluster, a parameter group or a backup; CloudTrail, for the tags of a trail; Budgets, for
+ * the tags of a budget or a budget action); 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/budgets/BudgetsService.java b/src/main/java/io/floci/aws/services/budgets/BudgetsService.java
index b530afbdd7..e794afbdbb 100644
--- a/src/main/java/io/floci/aws/services/budgets/BudgetsService.java
+++ b/src/main/java/io/floci/aws/services/budgets/BudgetsService.java
@@ -9,7 +9,9 @@ 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;
+import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.common.Resettable;
+import io.floci.aws.core.common.StoredResourceArns;
import io.floci.aws.core.common.UuidShapes;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.StorageFactory;
@@ -26,12 +28,13 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
@ApplicationScoped
-public class BudgetsService implements Resettable {
+public class BudgetsService implements Resettable, StoredResourceArns {
private static final Pattern ACCOUNT_ID = Pattern.compile("\\d{12}");
private static final Pattern IAM_POLICY_ARN = Pattern.compile("^arn:" + AwsArnUtils.PARTITION_REGEX + ":iam::(?:\\d{12}|aws):policy/.+$");
private static final Pattern SCP_POLICY_ID = Pattern.compile("^p-[0-9a-zA-Z_]{8,128}$");
@@ -51,24 +54,78 @@ public class BudgetsService implements Resettable {
private static final int MAX_NOTIFICATIONS = 10;
private static final int MAX_EMAIL_SUBSCRIBERS = 10;
+ /** What a budget's ARN resource starts with, its name following. */
+ private static final String BUDGET_RESOURCE = "budget/";
+ /** What follows a budget's ARN in the ARN of one of its actions, the action's id following. */
+ private static final String ACTION_SEGMENT = "/action/";
+
private final AccountAwareStorageBackend budgets;
private final AccountAwareStorageBackend actions;
private final ObjectMapper objectMapper;
+ private final RegionResolver regionResolver;
@Inject
- public BudgetsService(StorageFactory storageFactory, ObjectMapper objectMapper) {
+ public BudgetsService(StorageFactory storageFactory, ObjectMapper objectMapper, RegionResolver regionResolver) {
this(
storageFactory.create("budgets", "budgets.json", new TypeReference