diff --git a/docs/services/iam.md b/docs/services/iam.md
index 2646c9fc57..80746ca9ad 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -3148,9 +3148,9 @@ floci populates:
CloudFormation for its stacks, stack sets and change sets, Lambda for its functions, their versions and aliases
(the function's tags), event source mappings, web functions, their revisions and endpoints (the web function's
tags), MicroVM images and network connectors, Glue for its schema registries and schemas and for the jobs,
- crawlers, triggers, workflows, connections, databases, tables and other resources it tags, and Step Functions for
- its state machines, their versions and executions (the state machine's tags) and activities. Tag keys differing
- only in case are one condition key holding every value.
+ crawlers, triggers, workflows, connections, databases, tables and other resources it tags, Step Functions for its
+ state machines, their versions and executions (the state machine's tags) and activities, and CodeBuild for its
+ projects and report groups. 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 2d0e7ff4d7..ed2d2eb274 100644
--- a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
+++ b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
@@ -31,9 +31,10 @@ import java.util.Optional;
* table bucket or a table; Lambda, for the layer version a layer version ARN selects, the image of a MicroVM and the
* execution of a callback, and the tags of a function, an event source mapping, a web function, a MicroVM image or a
* network connector; Glue, for the tags of a resource it tags; Step Functions, for the tags of a state machine, its
- * versions and executions, and an activity); 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.
+ * versions and executions, and an activity; CodeBuild, for the project a build belongs to and the tags of a project or
+ * a report group); 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/codebuild/CodeBuildService.java b/src/main/java/io/floci/aws/services/codebuild/CodeBuildService.java
index 74386a9ee7..44c164177a 100644
--- a/src/main/java/io/floci/aws/services/codebuild/CodeBuildService.java
+++ b/src/main/java/io/floci/aws/services/codebuild/CodeBuildService.java
@@ -7,7 +7,9 @@ import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.EpochSeconds;
+import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.StorageBackedMap;
+import io.floci.aws.core.storage.StorageBackend;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.codebuild.model.Build;
import io.floci.aws.services.codebuild.model.BuildPhase;
@@ -24,9 +26,11 @@ import jakarta.inject.Inject;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.LinkedHashMap;
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.concurrent.CopyOnWriteArrayList;
@@ -43,6 +47,9 @@ public class CodeBuildService {
private Map> projects = new ConcurrentHashMap<>();
// key: region -> arn -> report group
private Map> reportGroups = new ConcurrentHashMap<>();
+ /** The backends of {@link #projects} and {@link #reportGroups}, read in another account than the caller's. */
+ private StorageBackend> projectStorage;
+ private StorageBackend> reportGroupStorage;
// key: region -> arn -> source credential (token is stored but never returned)
private Map> sourceCredentials = new ConcurrentHashMap<>();
// key: account:region -> buildId -> build (transient: builds are runtime state)
@@ -70,10 +77,12 @@ public class CodeBuildService {
if (storageFactory == null) {
return; // keeps non-CDI unit tests working
}
- this.projects = storageBacked("codebuild-projects.json",
+ this.projectStorage = storageFactory.create("codebuild", "codebuild-projects.json",
new TypeReference