fix(bedrock-agentcore): use runtime IDs and endpoint names in ARNs (#8088)

* fix(bedrock-agentcore): use runtime IDs and endpoint names in ARNs

Keep runtime ARNs stable across versions and use the parent runtime ID and endpoint name for endpoint ARNs. Update API responses, ARN lookups, tagging dispatch and CloudFormation references together.

* fix(bedrock-agentcore): preserve legacy and harness runtime lookups
This commit is contained in:
galsuchetzky-act authored and GitHub committed 2026-11-12 08:17:29 -04:00
1 parent 8bdf86420b
commit f2a0bfce4e
23 files changed
+360 -94

No files matched your search

@@ -63,7 +63,7 @@ class BedrockAgentCoreControlTest {
assertThat(runtimeId).startsWith(runtimeName + "-");
assertThat(response.agentRuntimeVersion()).isEqualTo("1");
assertThat(response.statusAsString()).isEqualTo("READY");
assertThat(response.agentRuntimeArn()).contains(":bedrock-agentcore:").contains(":agent/");
assertThat(response.agentRuntimeArn()).contains(":bedrock-agentcore:").contains(":runtime/" + runtimeId);
assertThat(response.workloadIdentityDetails().workloadIdentityArn()).isNotBlank();
}
@@ -66,7 +66,7 @@ class BedrockAgentCoreEndpointTest {
assertThat(response.endpointName()).isEqualTo("prod");
assertThat(response.targetVersion()).isEqualTo("1");
assertThat(response.statusAsString()).isEqualTo("READY");
assertThat(response.agentRuntimeEndpointArn()).contains(":agentEndpoint/");
assertThat(response.agentRuntimeEndpointArn()).contains(":runtime/" + runtimeId + "/runtime-endpoint/prod");
}
@Test
@@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.*;
class BedrockAgentCoreInvokeTest {
private static final String ARN =
"arn:aws:bedrock-agentcore:us-east-1:000000000000:agent/abcdef12-3456-7890-abcd-ef1234567890:1";
"arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/test-AbCdEfGhIj";
private static final String SESSION_ID = "session-0000000000000000000000000000abc";
@Test
+2 -2
View File
@@ -95,7 +95,7 @@ All verified against the AWS API reference. **Note verbs and trailing slashes.**
| DeleteAgentRuntime | `DELETE /runtimes/{agentRuntimeId}/?clientToken={t}` | 202 | body `{agentRuntimeId, status: DELETING}` |
Identity: `agentRuntimeId` = `<name>-<10 [a-zA-Z0-9]>` (`[a-zA-Z][a-zA-Z0-9_]{0,99}-[a-zA-Z0-9]{10}`).
ARN embeds a fresh UUID + version: `arn:aws:bedrock-agentcore:<region>:<account>:agent/<uuid>:<version>`.
Runtime ARN: `arn:<partition>:bedrock-agentcore:<region>:<account>:runtime/<agentRuntimeId>`, stable across versions.
`agentRuntimeVersion` is a string int starting `"1"`, incremented on Update. `status` = `READY`.
### Agent Runtime Endpoint (control plane)
@@ -108,7 +108,7 @@ ARN embeds a fresh UUID + version: `arn:aws:bedrock-agentcore:<region>:<account>
| DeleteAgentRuntimeEndpoint | `DELETE /runtimes/{agentRuntimeId}/runtime-endpoints/{endpointName}/?clientToken={t}` | 202 |
| ListAgentRuntimeEndpoints | `POST /runtimes/{agentRuntimeId}/runtime-endpoints/?maxResults=&nextToken=` | 200 |
Endpoint ARN `arn:aws:bedrock-agentcore:<region>:<account>:agentEndpoint/<uuid>` (no version).
Endpoint ARN `arn:<partition>:bedrock-agentcore:<region>:<account>:runtime/<agentRuntimeId>/runtime-endpoint/<name>`.
Create body: `name` (required), `agentRuntimeVersion`/`description`/`clientToken`/`tags` (optional).
Fields: `liveVersion` (serving) vs `targetVersion` (requested). A `DEFAULT` endpoint is auto-created
on runtime create so an unqualified invoke resolves.
+11 -2
View File
@@ -90,6 +90,12 @@ runtimes reach `READY` immediately and hold metadata only. See
A `DEFAULT` endpoint is created automatically with each runtime, and each runtime
is associated with an auto-created, resolvable workload identity.
Legacy `agent/<uuid>:<version>` runtime ARNs remain usable for invocation validation and tagging.
Legacy `agentEndpoint/<uuid>` endpoint IDs resolve for tagging and CloudFormation updates and deletes.
Responses use `runtime/<agentRuntimeId>` and `runtime/<agentRuntimeId>/runtime-endpoint/<name>`.
With runtime existence validation enabled, a harness runtime ARN is valid while its harness remains
registered; unknown and deleted runtime ARNs return `ResourceNotFoundException`.
## Memory events
The event data plane is backed by real storage, so what a read returns is what was written rather
@@ -112,6 +118,8 @@ rather than on stored events.
## Harnesses
Harness tags use the `harness/<id>` ARN. Tagging a harness runtime-environment ARN is not emulated.
A harness is stored with its configuration and settles in `READY` at once. No agent runtime is
started for it, and `InvokeHarness` does not read it.
@@ -190,8 +198,9 @@ block is ever produced even when a request supplies `tools`.
## Behavior notes
- `agentRuntimeId` is `<name>-<10 alphanumerics>`; the ARN embeds a UUID and the
version: `arn:aws:bedrock-agentcore:<region>:<account>:agent/<uuid>:<version>`.
- `agentRuntimeId` is `<name>-<10 alphanumerics>`; the runtime ARN is
`arn:<partition>:bedrock-agentcore:<region>:<account>:runtime/<agentRuntimeId>` and
stays the same across versions. Endpoint ARNs append `/runtime-endpoint/<name>`, including `DEFAULT`.
- `agentRuntimeName` must match `[a-zA-Z][a-zA-Z0-9_]{0,47}` (no hyphens); invalid
names return `ValidationException`.
- Each `UpdateAgentRuntime` increments the version and preserves prior versions for
@@ -12,9 +12,8 @@ final class BedrockAgentCoreArns {
}
/**
* The resource of an AgentCore ARN without its qualifier: {@code agent/<uuid>} for
* {@code arn:aws:bedrock-agentcore:<region>:<account>:agent/<uuid>:<version>}. Null when the value
* is not an ARN.
* The resource of an AgentCore ARN without a colon qualifier, including nested runtime endpoint
* paths. Null when the value is not an ARN.
*/
static String resource(String arn) {
if (!AwsArnUtils.isArn(arn)) {
@@ -78,7 +78,7 @@ public class BedrockAgentCoreControlController {
String version = String.valueOf(runtime.getLatestVersion());
ObjectNode out = objectMapper.createObjectNode();
out.put("agentRuntimeArn", service.arn(runtime, version, region));
out.put("agentRuntimeArn", service.arn(runtime, region));
out.put("agentRuntimeId", runtime.getAgentRuntimeId());
out.put("agentRuntimeVersion", version);
putInstant(out, "createdAt", runtime.getCreatedAt());
@@ -125,7 +125,7 @@ public class BedrockAgentCoreControlController {
String v = snap.getVersion();
ObjectNode out = objectMapper.createObjectNode();
out.put("agentRuntimeArn", service.arn(runtime, v, region));
out.put("agentRuntimeArn", service.arn(runtime, region));
out.put("agentRuntimeId", runtime.getAgentRuntimeId());
out.put("agentRuntimeName", runtime.getAgentRuntimeName());
out.put("agentRuntimeVersion", v);
@@ -181,7 +181,7 @@ public class BedrockAgentCoreControlController {
String version = String.valueOf(runtime.getLatestVersion());
ObjectNode out = objectMapper.createObjectNode();
out.put("agentRuntimeArn", service.arn(runtime, version, region));
out.put("agentRuntimeArn", service.arn(runtime, region));
out.put("agentRuntimeId", runtime.getAgentRuntimeId());
out.put("agentRuntimeVersion", version);
putInstant(out, "createdAt", runtime.getCreatedAt());
@@ -339,8 +339,8 @@ public class BedrockAgentCoreControlController {
private ObjectNode endpointResponse(AgentRuntime runtime, AgentRuntimeEndpoint endpoint,
String region, boolean full) {
ObjectNode node = objectMapper.createObjectNode();
node.put("agentRuntimeArn", service.arn(runtime, endpoint.getTargetVersion(), region));
node.put("agentRuntimeEndpointArn", service.endpointArn(endpoint, region));
node.put("agentRuntimeArn", service.arn(runtime, region));
node.put("agentRuntimeEndpointArn", service.endpointArn(runtime.getAgentRuntimeId(), endpoint, region));
node.put("agentRuntimeId", runtime.getAgentRuntimeId());
node.put("endpointName", endpoint.getName());
node.put("status", endpoint.getStatus());
@@ -364,7 +364,7 @@ public class BedrockAgentCoreControlController {
private ObjectNode summary(AgentRuntime runtime, String version, String region) {
ObjectNode node = objectMapper.createObjectNode();
node.put("agentRuntimeArn", service.arn(runtime, version, region));
node.put("agentRuntimeArn", service.arn(runtime, region));
node.put("agentRuntimeId", runtime.getAgentRuntimeId());
node.put("agentRuntimeName", runtime.getAgentRuntimeName());
node.put("agentRuntimeVersion", version);
@@ -378,7 +378,7 @@ public class BedrockAgentCoreControlController {
private ObjectNode versionSummary(AgentRuntime runtime, AgentRuntimeVersion snap, String region) {
ObjectNode node = objectMapper.createObjectNode();
node.put("agentRuntimeArn", service.arn(runtime, snap.getVersion(), region));
node.put("agentRuntimeArn", service.arn(runtime, region));
node.put("agentRuntimeId", runtime.getAgentRuntimeId());
node.put("agentRuntimeName", runtime.getAgentRuntimeName());
node.put("agentRuntimeVersion", snap.getVersion());
@@ -26,6 +26,7 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Pattern;
/**
@@ -54,6 +55,7 @@ public class BedrockAgentCoreControlService {
private final RegionResolver regionResolver;
private final StripedLocks runtimeLocks = new StripedLocks(RUNTIME_LOCK_STRIPES);
private final BedrockAgentCoreIdentityService identityService;
private final BedrockAgentCoreHarnessRegistry harnessRegistry;
// clientToken idempotency: tokens of completed deletes, so a replayed delete succeeds
// instead of 404ing. In-memory only (reset on restart), and each entry expires after
// DeletedTokenLedger.TTL, after which a replay 404s like an unknown token.
@@ -62,9 +64,10 @@ public class BedrockAgentCoreControlService {
@Inject
public BedrockAgentCoreControlService(StorageFactory storageFactory, RegionResolver regionResolver,
BedrockAgentCoreIdentityService identityService, Clock clock) {
BedrockAgentCoreIdentityService identityService, Clock clock,
BedrockAgentCoreHarnessRegistry harnessRegistry) {
this(storageFactory.create("bedrockagentcore", "bedrock-agentcore-runtimes.json",
new TypeReference<Map<String, AgentRuntime>>() {}), regionResolver, identityService, clock);
new TypeReference<Map<String, AgentRuntime>>() {}), regionResolver, identityService, clock, harnessRegistry);
}
BedrockAgentCoreControlService(StorageBackend<String, AgentRuntime> storage, RegionResolver regionResolver) {
@@ -78,9 +81,16 @@ public class BedrockAgentCoreControlService {
BedrockAgentCoreControlService(StorageBackend<String, AgentRuntime> storage, RegionResolver regionResolver,
BedrockAgentCoreIdentityService identityService, Clock clock) {
this(storage, regionResolver, identityService, clock, null);
}
BedrockAgentCoreControlService(StorageBackend<String, AgentRuntime> storage, RegionResolver regionResolver,
BedrockAgentCoreIdentityService identityService, Clock clock,
BedrockAgentCoreHarnessRegistry harnessRegistry) {
this.storage = storage;
this.regionResolver = regionResolver;
this.identityService = identityService;
this.harnessRegistry = harnessRegistry;
this.deletedRuntimeTokens = new DeletedTokenLedger(clock);
this.deletedEndpointTokens = new DeletedTokenLedger(clock);
}
@@ -289,8 +299,8 @@ public class BedrockAgentCoreControlService {
return String.format("%05d", Integer.parseInt(version));
}
public String arn(AgentRuntime runtime, String version, String region) {
return regionResolver.buildArn(ARN_SERVICE, region, "agent/" + runtime.getUuid() + ":" + version);
public String arn(AgentRuntime runtime, String region) {
return regionResolver.buildArn(ARN_SERVICE, region, "runtime/" + runtime.getAgentRuntimeId());
}
/**
@@ -300,17 +310,24 @@ public class BedrockAgentCoreControlService {
*/
public boolean runtimeArnExists(String region, String arn) {
String resource = BedrockAgentCoreArns.resource(arn);
if (resource == null || !resource.startsWith("agent/")) {
if (resource == null || (!resource.startsWith("runtime/") && !resource.startsWith("agent/"))) {
return true;
}
String uuid = resource.substring("agent/".length());
String prefix = keyPrefix(region);
return storage.scan(k -> k.startsWith(prefix)).stream()
.anyMatch(r -> uuid.equals(r.getUuid()));
return findRuntimeByResource(region, resource).isPresent()
|| (harnessRegistry != null && harnessRegistry.runtimeArnExists(region, arn));
}
public String endpointArn(AgentRuntimeEndpoint endpoint, String region) {
return regionResolver.buildArn(ARN_SERVICE, region, "agentEndpoint/" + endpoint.getUuid());
private Optional<AgentRuntime> findRuntimeByResource(String region, String resource) {
boolean legacy = resource.startsWith("agent/");
String id = resource.substring(legacy ? "agent/".length() : "runtime/".length());
return storage.scan(k -> k.startsWith(keyPrefix(region))).stream()
.filter(runtime -> id.equals(legacy ? runtime.getUuid() : runtime.getAgentRuntimeId()))
.findFirst();
}
public String endpointArn(String runtimeId, AgentRuntimeEndpoint endpoint, String region) {
return regionResolver.buildArn(ARN_SERVICE, region,
"runtime/" + runtimeId + "/runtime-endpoint/" + endpoint.getName());
}
// ──────────────────────────── Tagging (Phase 4) ────────────────────────────
@@ -341,13 +358,9 @@ public class BedrockAgentCoreControlService {
}
}
/** The runtime a runtime ARN names, at any version; ResourceNotFoundException when none does. */
/** The runtime a runtime ARN names; ResourceNotFoundException when none does. */
public AgentRuntime getAgentRuntimeByArn(String region, String arn) {
String uuid = uuidFromArn(arn);
String prefix = keyPrefix(region);
return storage.scan(k -> k.startsWith(prefix)).stream()
.filter(r -> uuid.equals(r.getUuid()))
.findFirst()
return findRuntimeByResource(region, runtimeResourceFromArn(arn))
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
"AgentCore resource not found: " + arn, 404));
}
@@ -390,13 +403,12 @@ public class BedrockAgentCoreControlService {
"AgentCore resource not found: " + arn, 404));
}
private static String uuidFromArn(String arn) {
// arn:aws:bedrock-agentcore:<region>:<account>:agent/<uuid>:<version>
private static String runtimeResourceFromArn(String arn) {
String resource = BedrockAgentCoreArns.resource(arn);
if (resource == null || !resource.startsWith("agent/")) {
if (resource == null || (!resource.startsWith("runtime/") && !resource.startsWith("agent/"))) {
throw new AwsException("ValidationException", "Unsupported resource ARN: " + arn, 400);
}
return resource.substring("agent/".length());
return resource;
}
// ──────────────────────────── Endpoints (Phase 2) ────────────────────────────
@@ -533,32 +545,38 @@ public class BedrockAgentCoreControlService {
public record EndpointLocation(AgentRuntime runtime, AgentRuntimeEndpoint endpoint) {
}
/**
* The endpoint an endpoint ARN ({@code agentEndpoint/<uuid>}) names, with its runtime, or empty
* when no runtime in the region holds it. Endpoints are addressed by runtime id and name on the
* API, so this is the only way back from the ARN CloudFormation keeps as the physical id.
*/
/** The endpoint and parent runtime named by a runtime endpoint ARN, or empty when absent. */
public Optional<EndpointLocation> findEndpointByArn(String region, String arn) {
String resource = BedrockAgentCoreArns.resource(arn);
if (resource == null || !resource.startsWith("agentEndpoint/")) {
if (resource == null) {
return Optional.empty();
}
String uuid = resource.substring("agentEndpoint/".length());
String prefix = keyPrefix(region);
for (AgentRuntime runtime : storage.scan(k -> k.startsWith(prefix))) {
synchronized (runtimeLock(region, runtime.getAgentRuntimeId())) {
Optional<AgentRuntime> current = storage.get(key(region, runtime.getAgentRuntimeId()));
if (current.isEmpty()) {
continue;
}
for (AgentRuntimeEndpoint endpoint : current.get().getEndpoints()) {
if (uuid.equals(endpoint.getUuid())) {
return Optional.of(new EndpointLocation(current.get(), endpoint));
}
if (resource.startsWith("agentEndpoint/")) {
String uuid = resource.substring("agentEndpoint/".length());
for (AgentRuntime candidate : storage.scan(k -> k.startsWith(keyPrefix(region)))) {
Optional<EndpointLocation> found = findEndpoint(region, candidate.getAgentRuntimeId(),
endpoint -> uuid.equals(endpoint.getUuid()));
if (found.isPresent()) {
return found;
}
}
return Optional.empty();
}
String[] parts = resource.split("/", -1);
if (parts.length != 4 || !"runtime".equals(parts[0]) || !"runtime-endpoint".equals(parts[2])) {
return Optional.empty();
}
return findEndpoint(region, parts[1], endpoint -> parts[3].equals(endpoint.getName()));
}
private Optional<EndpointLocation> findEndpoint(String region, String runtimeId,
Predicate<AgentRuntimeEndpoint> matches) {
synchronized (runtimeLock(region, runtimeId)) {
return storage.get(key(region, runtimeId)).flatMap(runtime -> runtime.getEndpoints().stream()
.filter(matches)
.map(endpoint -> new EndpointLocation(runtime, endpoint))
.findFirst());
}
return Optional.empty();
}
private Object runtimeLock(String region, String runtimeId) {
@@ -194,6 +194,13 @@ public class BedrockAgentCoreHarnessRegistry {
return new HarnessView(harness, harness.getCurrentVersion());
}
public synchronized boolean runtimeArnExists(String region, String arn) {
return storage.scan(key -> key.startsWith(keyPrefix(region))).stream()
.flatMap(harness -> harness.getVersions().stream())
.anyMatch(version -> arn.equals(version.getConfiguration().path("environment")
.path(RUNTIME_ENVIRONMENT).path("agentRuntimeArn").asText(null)));
}
public PaginatedResult<Harness> list(Integer maxResults, String nextToken, String region) {
List<Harness> all = storage.scan(key -> key.startsWith(keyPrefix(region)));
return Pagination.paginate(all, Harness::getHarnessId, maxResults, nextToken, MAX_PAGE, "ValidationException");
@@ -88,11 +88,14 @@ public class BedrockAgentCoreTagHandler implements TagHandler {
if (resource.startsWith("gateway/")) {
return ResourceKind.GATEWAY;
}
if (resource.startsWith("agentEndpoint/")) {
return ResourceKind.ENDPOINT;
}
if (resource.startsWith("agent/")) {
return ResourceKind.RUNTIME;
}
if (resource.startsWith("agentEndpoint/")) {
return ResourceKind.ENDPOINT;
if (resource.startsWith("runtime/")) {
return resource.contains("/runtime-endpoint/") ? ResourceKind.ENDPOINT : ResourceKind.RUNTIME;
}
if (resource.startsWith("memory/")) {
return ResourceKind.MEMORY;
@@ -152,7 +152,7 @@ public class BedrockAgentCoreCfnProvisioner implements CfnResourceProvisioner {
&& Objects.equals(authorizer, prior.getAuthorizerConfiguration())
&& Objects.equals(protocolConfiguration, prior.getProtocolConfiguration())
&& environment.equals(prior.getEnvironmentVariables()));
String arn = runtimeService.arn(prior, String.valueOf(prior.getLatestVersion()), region);
String arn = runtimeService.arn(prior, region);
Map<String, String> priorTags = runtimeService.getTagsByArn(region, arn);
if (configurationChanged || !priorTags.equals(tags)) {
ObjectNode snapshot = inPlacePrior(prior.getAgentRuntimeId(), region);
@@ -205,7 +205,7 @@ public class BedrockAgentCoreCfnProvisioner implements CfnResourceProvisioner {
private void publishRuntime(StackResource r, AgentRuntime runtime, String region) {
String version = String.valueOf(runtime.getLatestVersion());
r.setPhysicalId(runtime.getAgentRuntimeId());
r.getAttributes().put("AgentRuntimeArn", runtimeService.arn(runtime, version, region));
r.getAttributes().put("AgentRuntimeArn", runtimeService.arn(runtime, region));
r.getAttributes().put("AgentRuntimeId", runtime.getAgentRuntimeId());
r.getAttributes().put("AgentRuntimeVersion", version);
r.getAttributes().put("Status", runtime.getStatus());
@@ -263,7 +263,7 @@ public class BedrockAgentCoreCfnProvisioner implements CfnResourceProvisioner {
} else {
AgentRuntimeEndpoint endpoint = runtimeService.createEndpoint(runtimeId, name, version, description,
null, region);
r.setPhysicalId(runtimeService.endpointArn(endpoint, region));
r.setPhysicalId(runtimeService.endpointArn(runtimeId, endpoint, region));
CfnRollback.guarded(r, ctx, true, () -> runtimeService.deleteEndpoint(runtimeId, name, null, region),
() -> undoInPlace(r),
() -> publishRuntimeEndpoint(r, runtimeService.getAgentRuntime(runtimeId, region), endpoint, region));
@@ -272,10 +272,10 @@ public class BedrockAgentCoreCfnProvisioner implements CfnResourceProvisioner {
private void publishRuntimeEndpoint(StackResource r, AgentRuntime runtime, AgentRuntimeEndpoint endpoint,
String region) {
String endpointArn = runtimeService.endpointArn(endpoint, region);
String endpointArn = runtimeService.endpointArn(runtime.getAgentRuntimeId(), endpoint, region);
r.setPhysicalId(endpointArn);
r.getAttributes().put("AgentRuntimeEndpointArn", endpointArn);
r.getAttributes().put("AgentRuntimeArn", runtimeService.arn(runtime, endpoint.getTargetVersion(), region));
r.getAttributes().put("AgentRuntimeArn", runtimeService.arn(runtime, region));
r.getAttributes().put("Id", endpoint.getUuid());
r.getAttributes().put("Status", endpoint.getStatus());
r.getAttributes().put("TargetVersion", endpoint.getTargetVersion());
@@ -478,7 +478,7 @@ public class BedrockAgentCoreCfnProvisioner implements CfnResourceProvisioner {
node(configuration, "authorizer"), node(configuration, "protocol"), region);
}
if (prior.has("tags")) {
reconcileRuntimeTags(runtimeService.arn(runtime, String.valueOf(runtime.getLatestVersion()), region),
reconcileRuntimeTags(runtimeService.arn(runtime, region),
stringMap(prior.get("tags")), region);
}
publishRuntime(resource, runtime, region);
@@ -12,7 +12,7 @@ import static org.hamcrest.Matchers.equalTo;
class BedrockAgentCoreInvokeIntegrationTest {
private static final String ARN =
"arn:aws:bedrock-agentcore:us-east-1:000000000000:agent/abcdef12-3456-7890-abcd-ef1234567890:1";
"arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/test-AbCdEfGhIj";
private static final String SESSION_ID = "session-0000000000000000000000000000abc";
private static final String SESSION_HEADER = "X-Amzn-Bedrock-AgentCore-Runtime-Session-Id";
@@ -8,6 +8,8 @@ import io.restassured.path.json.JsonPath;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import java.util.UUID;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@@ -52,9 +54,40 @@ class BedrockAgentCoreInvokeValidateIntegrationTest {
@Test
void invokeUnknownRuntimeReturns404() {
String unknown =
"arn:aws:bedrock-agentcore:us-east-1:000000000000:agent/00000000-0000-0000-0000-000000000000:1";
"arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/missing-AbCdEfGhIj";
given().contentType("application/json").body("{}")
.when().post("/runtimes/" + unknown + "/invocations")
.then().statusCode(404);
}
@Test
void invokeUnknownLegacyRuntimeReturns404() {
given().contentType("application/json").body("{}")
.post("/runtimes/arn:aws:bedrock-agentcore:us-east-1:000000000000:agent/unknown:1/invocations")
.then().statusCode(404);
}
@Test
void harnessRuntimeExistsOnlyWhileItsHarnessIsRegistered() {
String name = "invoke" + UUID.randomUUID().toString().replace("-", "");
JsonPath harness = given().contentType("application/json").body("""
{"harnessName":"%s","executionRoleArn":"arn:aws:iam::000000000000:role/harness",
"model":{"bedrockModelConfig":{"modelId":"test-model"}}}
""".formatted(name)).post("/harnesses").then().statusCode(201).extract().jsonPath();
String id = harness.getString("harness.harnessId");
String arn = harness.getString("harness.environment.agentCoreRuntimeEnvironment.agentRuntimeArn");
cleanup.register(() -> given().delete("/harnesses/" + id));
given().contentType("application/json").body("{}").post("/runtimes/" + arn + "/invocations")
.then().statusCode(200);
given().delete("/harnesses/" + id).then().statusCode(200);
given().contentType("application/json").body("{}").post("/runtimes/" + arn + "/invocations")
.then().statusCode(404);
}
@Test
void anInventedHarnessRuntimeDoesNotPassValidation() {
given().contentType("application/json").body("{}")
.post("/runtimes/arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/harness_missing-AbCdEfGhIj/invocations")
.then().statusCode(404);
}
}
@@ -9,8 +9,8 @@ class BedrockAgentCoreArnsTest {
@Test
void resourceDropsTheQualifier() {
assertEquals("agent/abc",
BedrockAgentCoreArns.resource("arn:aws:bedrock-agentcore:us-east-1:123456789012:agent/abc:7"));
assertEquals("runtime/test-AbCdEfGhIj",
BedrockAgentCoreArns.resource("arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/test-AbCdEfGhIj:7"));
}
@Test
@@ -22,7 +22,7 @@ class BedrockAgentCoreArnsTest {
@Test
void resourceIsNullForAnythingThatIsNotAnArn() {
assertNull(BedrockAgentCoreArns.resource(null));
assertNull(BedrockAgentCoreArns.resource("agent/abc"));
assertNull(BedrockAgentCoreArns.resource("runtime/test-AbCdEfGhIj"));
assertNull(BedrockAgentCoreArns.resource("arn:aws:bedrock-agentcore:us-east-1"));
}
}
@@ -32,7 +32,7 @@ final class BedrockAgentCoreConcurrencyFixture {
AgentRuntime runtime = service.createAgentRuntime("probe", artifact, network,
"arn:aws:iam::000000000000:role/probe", null, null, null, null, null, REGION);
runtimeId = runtime.getAgentRuntimeId();
arn = service.arn(runtime, "1", REGION);
arn = service.arn(runtime, REGION);
}
AgentRuntime delete() {
@@ -46,7 +46,7 @@ class BedrockAgentCoreControlIntegrationTest {
.body("agentRuntimeVersion", equalTo("1"))
.body("status", equalTo("READY"))
.body("agentRuntimeArn", containsString(":bedrock-agentcore:"))
.body("agentRuntimeArn", containsString(":agent/"))
.body("agentRuntimeArn", containsString(":runtime/"))
.body("workloadIdentityDetails.workloadIdentityArn", notNullValue())
.extract().path("agentRuntimeId");
}
@@ -66,9 +66,9 @@ class BedrockAgentCoreControlServiceTest {
assertEquals(1, rt.getLatestVersion());
assertEquals("READY", rt.getStatus());
assertTrue(rt.getWorkloadIdentityArn().contains(":bedrock-agentcore:"));
assertTrue(service.arn(rt, "1", REGION)
.matches("arn:aws:bedrock-agentcore:us-east-1:000000000000:agent/[0-9a-f-]{36}:1"),
service.arn(rt, "1", REGION));
assertTrue(service.arn(rt, REGION)
.equals("arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/" + rt.getAgentRuntimeId()),
service.arn(rt, REGION));
}
@Test
@@ -442,7 +442,7 @@ class BedrockAgentCoreControlServiceTest {
String id = rt.getAgentRuntimeId();
AgentRuntimeEndpoint ep = service.createEndpoint(id, "prod", null, null,
Map.of("env", "prod"), null, REGION);
String endpointArn = service.endpointArn(ep, REGION);
String endpointArn = service.endpointArn(id, ep, REGION);
assertEquals(Map.of("env", "prod"), service.getEndpointTagsByArn(REGION, endpointArn));
@@ -451,7 +451,7 @@ class BedrockAgentCoreControlServiceTest {
assertEquals(Map.of("team", "ml"), service.getEndpointTagsByArn(REGION, endpointArn));
assertEquals(Map.of("owner", "runtime"),
service.getTagsByArn(REGION, service.arn(rt, "1", REGION)));
service.getTagsByArn(REGION, service.arn(rt, REGION)));
assertTrue(service.getEndpoint(id, "DEFAULT", REGION).getTags().isEmpty());
}
@@ -461,7 +461,7 @@ class BedrockAgentCoreControlServiceTest {
String id = rt.getAgentRuntimeId();
AgentRuntimeEndpoint ep = service.createEndpoint(id, "prod", null, null,
Map.of("fixed", "1"), null, REGION);
String endpointArn = service.endpointArn(ep, REGION);
String endpointArn = service.endpointArn(id, ep, REGION);
AtomicInteger inconsistent = new AtomicInteger();
try (ExecutorService executor = Executors.newFixedThreadPool(3)) {
Future<?> writer = executor.submit(() -> {
@@ -503,7 +503,7 @@ class BedrockAgentCoreControlServiceTest {
String id = rt.getAgentRuntimeId();
AgentRuntimeEndpoint ep = service.createEndpoint(id, "prod", null, null,
Map.of("env", "prod"), null, REGION);
String endpointArn = service.endpointArn(ep, REGION);
String endpointArn = service.endpointArn(id, ep, REGION);
service.deleteEndpoint(id, "prod", null, REGION);
@@ -51,7 +51,7 @@ class BedrockAgentCoreEndpointIntegrationTest {
.body("endpointName", equalTo("prod"))
.body("targetVersion", equalTo("1"))
.body("status", equalTo("READY"))
.body("agentRuntimeEndpointArn", containsString(":agentEndpoint/"));
.body("agentRuntimeEndpointArn", containsString("/runtime-endpoint/prod"));
}
@Test
@@ -199,8 +199,8 @@ class BedrockAgentCoreEndpointIntegrationTest {
given().when().delete("/tags/" + endpointArn + "?tagKeys=a")
.then().statusCode(404).body("__type", equalTo("ResourceNotFoundException"));
String missingRuntimeArn = endpointArn.replaceAll("agentEndpoint/.*", "agent/missing0000-AbCdEfGhIj");
String existingRuntimeArn = endpointArn.replaceAll("agentEndpoint/.*", "agent/" + id);
String missingRuntimeArn = endpointArn.replaceAll("runtime/.*", "runtime/missing0000-AbCdEfGhIj");
String existingRuntimeArn = endpointArn.replaceAll("runtime/.*", "runtime/" + id);
for (String runtimeTarget : new String[] {missingRuntimeArn,
existingRuntimeArn.replace(":000000000000:", ":222222222222:"),
existingRuntimeArn.replace(":us-east-1:", ":eu-west-1:"),
@@ -56,7 +56,7 @@ class BedrockAgentCorePersistenceTest {
"arn:aws:iam::000000000000:role/agent", "v2", Map.of("K", "V"), authorizer, null, REGION);
svc.createEndpoint(id, "prod", "1", "prod ep", Map.of("stage", "live"), null, REGION);
AgentRuntime before = svc.getAgentRuntime(id, REGION);
svc.tagByArn(REGION, svc.arn(before, "1", REGION), Map.of("env", "prod"));
svc.tagByArn(REGION, svc.arn(before, REGION), Map.of("env", "prod"));
before = svc.getAgentRuntime(id, REGION);
// Write to disk, then reload into a brand-new backend (simulated restart).
@@ -0,0 +1,197 @@
package io.floci.aws.services.bedrockagentcorecontrol;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.InMemoryStorage;
import io.floci.aws.services.bedrockagentcorecontrol.model.AgentRuntime;
import io.floci.aws.services.bedrockagentcorecontrol.model.AgentRuntimeEndpoint;
import io.floci.aws.services.cloudformation.CloudFormationTemplateEngine;
import io.floci.aws.services.cloudformation.model.StackResource;
import io.floci.aws.services.cloudformation.provisioners.BedrockAgentCoreCfnProvisioner;
import io.floci.aws.services.cloudformation.provisioners.ProvisionContext;
import io.floci.aws.testing.MutableClock;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
class BedrockAgentCoreRuntimeArnTest {
private static final String REGION = "us-east-1";
private static final String PREFIX = "arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/";
private final ObjectMapper mapper = new ObjectMapper();
private final RegionResolver resolver = new RegionResolver(REGION, "000000000000");
private final BedrockAgentCoreControlService service = new BedrockAgentCoreControlService(
new InMemoryStorage<>(), resolver, null, new MutableClock());
private ObjectNode artifact() {
return mapper.createObjectNode().set("containerConfiguration",
mapper.createObjectNode().put("containerUri", "123456789012.dkr.ecr/x:latest"));
}
private ObjectNode network() {
return mapper.createObjectNode().put("networkMode", "PUBLIC");
}
private AgentRuntime create(String name) {
return service.createAgentRuntime(name, artifact(), network(),
"arn:aws:iam::000000000000:role/agent", null, null, null, null, null, REGION);
}
@Test
void runtimeArnUsesTheRuntimeIdAndStaysStableAcrossVersions() {
AgentRuntime runtime = create("versioned");
String expected = PREFIX + runtime.getAgentRuntimeId();
assertEquals(expected, service.arn(runtime, REGION));
AgentRuntime updated = service.updateAgentRuntime(runtime.getAgentRuntimeId(), artifact(), network(),
"arn:aws:iam::000000000000:role/agent", null, null, null, null, REGION);
assertEquals(expected, service.arn(updated, REGION));
}
@Test
void runtimeArnResolvesItsIdAndChecksDeletedRuntimes() {
AgentRuntime runtime = create("lookup");
String arn = PREFIX + runtime.getAgentRuntimeId();
assertEquals(runtime.getAgentRuntimeId(), service.getAgentRuntimeByArn(REGION, arn).getAgentRuntimeId());
assertTrue(service.runtimeArnExists(REGION, arn));
service.deleteAgentRuntime(runtime.getAgentRuntimeId(), null, REGION);
assertFalse(service.runtimeArnExists(REGION, arn));
}
@Test
void missingRuntimeArnDoesNotPassTheExistenceCheck() {
assertFalse(service.runtimeArnExists(REGION, PREFIX + "missing-AbCdEfGhIj"));
}
@Test
void endpointArnIncludesItsParentAndNameIncludingDefault() {
AgentRuntime runtime = create("endpoints");
AgentRuntimeEndpoint endpoint = service.createEndpoint(runtime.getAgentRuntimeId(), "prod",
null, null, null, REGION);
assertEquals(PREFIX + runtime.getAgentRuntimeId() + "/runtime-endpoint/prod",
service.endpointArn(runtime.getAgentRuntimeId(), endpoint, REGION));
AgentRuntimeEndpoint defaultEndpoint = service.getEndpoint(runtime.getAgentRuntimeId(), "DEFAULT", REGION);
assertEquals(PREFIX + runtime.getAgentRuntimeId() + "/runtime-endpoint/DEFAULT",
service.endpointArn(runtime.getAgentRuntimeId(), defaultEndpoint, REGION));
}
@Test
void endpointLookupUsesTheParentWhenNamesRepeat() {
AgentRuntime first = create("first");
AgentRuntime second = create("second");
service.createEndpoint(first.getAgentRuntimeId(), "prod", null, null, null, REGION);
service.createEndpoint(second.getAgentRuntimeId(), "prod", null, null, null, REGION);
String arn = PREFIX + second.getAgentRuntimeId() + "/runtime-endpoint/prod";
BedrockAgentCoreControlService.EndpointLocation located = service.findEndpointByArn(REGION, arn).orElseThrow();
assertEquals(second.getAgentRuntimeId(), located.runtime().getAgentRuntimeId());
assertEquals("prod", located.endpoint().getName());
assertTrue(service.findEndpointByArn("us-west-2", arn).isEmpty());
service.deleteEndpoint(second.getAgentRuntimeId(), "prod", null, REGION);
assertTrue(service.findEndpointByArn(REGION, arn).isEmpty());
}
@Test
void tagHandlerDispatchesRuntimeAndNestedEndpointArnsSeparately() {
AgentRuntime runtime = create("tagged");
service.createEndpoint(runtime.getAgentRuntimeId(), "prod", null, null, null, REGION);
String runtimeArn = PREFIX + runtime.getAgentRuntimeId();
String endpointArn = runtimeArn + "/runtime-endpoint/prod";
BedrockAgentCoreTagHandler handler = new BedrockAgentCoreTagHandler(service,
mock(BedrockAgentCoreGatewayService.class), mock(BedrockAgentCoreMemoryService.class),
mock(BedrockAgentCoreHarnessRegistry.class), resolver);
handler.tagResource(REGION, runtimeArn, Map.of("owner", "runtime"));
handler.tagResource(REGION, endpointArn, Map.of("owner", "endpoint"));
assertEquals(Map.of("owner", "runtime"), handler.listTags(REGION, runtimeArn));
assertEquals(Map.of("owner", "endpoint"), handler.listTags(REGION, endpointArn));
handler.untagResource(REGION, endpointArn, List.of("owner"));
assertTrue(handler.listTags(REGION, endpointArn).isEmpty());
assertEquals(Map.of("owner", "runtime"), handler.listTags(REGION, runtimeArn));
}
@Test
void unknownLegacyRuntimeDoesNotPassExistenceValidation() {
assertFalse(service.runtimeArnExists(REGION,
resolver.buildArn("bedrock-agentcore", REGION, "agent/missing-uuid:1")));
}
@Test
void legacyRuntimeExistenceFollowsItsStoredUuidAndDeletion() {
AgentRuntime runtime = create("legacyRuntime");
String arn = resolver.buildArn("bedrock-agentcore", REGION, "agent/" + runtime.getUuid() + ":1");
assertTrue(service.runtimeArnExists(REGION, arn));
service.deleteAgentRuntime(runtime.getAgentRuntimeId(), null, REGION);
assertFalse(service.runtimeArnExists(REGION, arn));
}
@Test
void legacyRuntimeAndEndpointTagsRemainSeparate() {
AgentRuntime runtime = create("legacyTags");
AgentRuntimeEndpoint endpoint = service.createEndpoint(runtime.getAgentRuntimeId(), "prod",
null, null, null, REGION);
String runtimeArn = resolver.buildArn("bedrock-agentcore", REGION, "agent/" + runtime.getUuid() + ":1");
String endpointArn = resolver.buildArn("bedrock-agentcore", REGION, "agentEndpoint/" + endpoint.getUuid());
BedrockAgentCoreTagHandler handler = new BedrockAgentCoreTagHandler(service,
mock(BedrockAgentCoreGatewayService.class), mock(BedrockAgentCoreMemoryService.class),
mock(BedrockAgentCoreHarnessRegistry.class), resolver);
handler.tagResource(REGION, runtimeArn, Map.of("scope", "runtime"));
handler.tagResource(REGION, endpointArn, Map.of("scope", "endpoint"));
assertEquals(Map.of("scope", "runtime"), handler.listTags(REGION, runtimeArn));
assertEquals(Map.of("scope", "endpoint"), handler.listTags(REGION, endpointArn));
assertEquals(runtime.getAgentRuntimeId(), service.getAgentRuntimeByArn(REGION, runtimeArn).getAgentRuntimeId());
}
@Test
void legacyEndpointLookupResolvesItsUuidAndDisappearsAfterDeletion() {
AgentRuntime runtime = create("legacyLookup");
AgentRuntimeEndpoint endpoint = service.createEndpoint(runtime.getAgentRuntimeId(), "prod",
null, null, null, REGION);
String arn = resolver.buildArn("bedrock-agentcore", REGION, "agentEndpoint/" + endpoint.getUuid());
assertEquals(runtime.getAgentRuntimeId(), service.findEndpointByArn(REGION, arn).orElseThrow()
.runtime().getAgentRuntimeId());
assertTrue(service.findEndpointByArn("us-west-2", arn).isEmpty());
service.deleteEndpoint(runtime.getAgentRuntimeId(), "prod", null, REGION);
assertTrue(service.findEndpointByArn(REGION, arn).isEmpty());
}
@Test
void cloudFormationUpdatesAnEndpointWithAPersistedLegacyPhysicalId() {
AgentRuntime runtime = create("legacyUpdate");
AgentRuntimeEndpoint endpoint = service.createEndpoint(runtime.getAgentRuntimeId(), "prod",
null, "old", null, REGION);
String arn = resolver.buildArn("bedrock-agentcore", REGION, "agentEndpoint/" + endpoint.getUuid());
StackResource resource = new StackResource();
resource.setLogicalId("Endpoint");
resource.setResourceType("AWS::BedrockAgentCore::RuntimeEndpoint");
resource.setPhysicalId(arn);
resource.setAttributes(new HashMap<>());
ObjectNode props = mapper.createObjectNode().put("AgentRuntimeId", runtime.getAgentRuntimeId())
.put("Name", "prod").put("Description", "new");
CloudFormationTemplateEngine engine = CloudFormationTemplateEngine.standalone("000000000000", REGION,
"legacy-stack", mapper, value -> value);
new BedrockAgentCoreCfnProvisioner(service, mock(BedrockAgentCoreMemoryService.class)).provision(
resource, props, new ProvisionContext(engine, REGION, "000000000000", "legacy-stack", arn));
assertEquals(service.endpointArn(runtime.getAgentRuntimeId(), endpoint, REGION), resource.getPhysicalId());
assertEquals("new", service.getEndpoint(runtime.getAgentRuntimeId(), "prod", REGION).getDescription());
assertEquals(2, service.getAgentRuntime(runtime.getAgentRuntimeId(), REGION).getEndpoints().size());
}
@Test
void cloudFormationDeletesAnEndpointWithAPersistedLegacyPhysicalId() {
AgentRuntime runtime = create("legacyDelete");
AgentRuntimeEndpoint endpoint = service.createEndpoint(runtime.getAgentRuntimeId(), "prod",
null, null, null, REGION);
String arn = resolver.buildArn("bedrock-agentcore", REGION, "agentEndpoint/" + endpoint.getUuid());
new BedrockAgentCoreCfnProvisioner(service, mock(BedrockAgentCoreMemoryService.class))
.delete("AWS::BedrockAgentCore::RuntimeEndpoint", arn, REGION);
assertThrows(AwsException.class, () -> service.getEndpoint(runtime.getAgentRuntimeId(), "prod", REGION));
}
}
@@ -24,7 +24,7 @@ class BedrockAgentCoreTagHandlerTest {
private static String endpointArn(String partition) {
return "arn:" + partition + ":bedrock-agentcore:" + CUSTOM_REGION + ":" + ACCOUNT
+ ":agentEndpoint/abc123";
+ ":runtime/test-AbCdEfGhIj/runtime-endpoint/prod";
}
@Test
@@ -210,7 +210,7 @@ class CloudFormationBedrockAgentCoreIntegrationTest {
String runtimeArn = outputs.get("RuntimeArn");
assertEquals(runtimeId, outputs.get("RuntimeRef"));
assertTrue(runtimeId.startsWith("cfn_agent_runtime-"), runtimeId);
assertTrue(runtimeArn.matches("arn:aws:bedrock-agentcore:us-east-1:000000000000:agent/[0-9a-f-]{36}:1"),
assertTrue(runtimeArn.matches("arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/[a-zA-Z][a-zA-Z0-9_]{0,47}-[a-zA-Z0-9]{10}"),
runtimeArn);
assertEquals("1", outputs.get("RuntimeVersion"));
assertEquals("READY", outputs.get("RuntimeStatus"));
@@ -219,7 +219,7 @@ class CloudFormationBedrockAgentCoreIntegrationTest {
String endpointArn = outputs.get("EndpointArn");
assertEquals(endpointArn, outputs.get("EndpointRef"));
assertTrue(endpointArn.startsWith("arn:aws:bedrock-agentcore:us-east-1:000000000000:agentEndpoint/"), endpointArn);
assertEquals(runtimeArn + "/runtime-endpoint/prod", endpointArn);
assertEquals(runtimeArn, outputs.get("EndpointRuntimeArn"));
assertEquals("1", outputs.get("EndpointTargetVersion"));
assertEquals("READY", outputs.get("EndpointStatus"));
@@ -46,7 +46,7 @@ class BedrockAgentCoreCfnProvisionerTest {
private static final String REGION = "us-east-1";
private static final String RUNTIME_ID = "agent-abcdefghij";
private static final String RUNTIME_ARN = "arn:aws:bedrock-agentcore:us-east-1:000000000000:agent/uuid:1";
private static final String RUNTIME_ARN = "arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/" + RUNTIME_ID;
private static final String MEMORY_ID = "mem-abcdefghij";
private static final String MEMORY_ARN = "arn:aws:bedrock-agentcore:us-east-1:000000000000:memory/" + MEMORY_ID;
private static final String ROLE_ARN = "arn:aws:iam::000000000000:role/agent";
@@ -127,7 +127,7 @@ class BedrockAgentCoreCfnProvisionerTest {
void aFnIfSelectingNoValueInsideNetworkConfigurationIsOmitted() {
when(runtimes.createAgentRuntime(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()))
.thenReturn(runtime(null, Map.of()));
when(runtimes.arn(any(), any(), eq(REGION))).thenReturn(RUNTIME_ARN);
when(runtimes.arn(any(), eq(REGION))).thenReturn(RUNTIME_ARN);
ObjectNode props = runtimeProps(mapper, null, "agents");
// No condition is defined, so Fn::If takes its else branch, as an undefined condition does.
props.set("NetworkConfiguration", json("""
@@ -148,7 +148,7 @@ class BedrockAgentCoreCfnProvisionerTest {
void aFailedTaggingAfterCreateDeletesTheRuntimeBeforePropagating() {
when(runtimes.createAgentRuntime(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()))
.thenReturn(runtime(null, Map.of()));
when(runtimes.arn(any(), any(), eq(REGION))).thenReturn(RUNTIME_ARN);
when(runtimes.arn(any(), eq(REGION))).thenReturn(RUNTIME_ARN);
doThrow(new AwsException("ThrottlingException", "slow down", 429))
.when(runtimes).tagByArn(eq(REGION), eq(RUNTIME_ARN), anyMap());
StackResource r = resource("AWS::BedrockAgentCore::Runtime");
@@ -173,7 +173,7 @@ class BedrockAgentCoreCfnProvisionerTest {
endpoint.setCreatedAt(Instant.EPOCH);
endpoint.setLastUpdatedAt(Instant.EPOCH);
when(runtimes.createEndpoint(RUNTIME_ID, "prod", null, null, null, REGION)).thenReturn(endpoint);
when(runtimes.endpointArn(endpoint, REGION)).thenReturn("arn:ep");
when(runtimes.endpointArn(RUNTIME_ID, endpoint, REGION)).thenReturn("arn:ep");
when(runtimes.getAgentRuntime(RUNTIME_ID, REGION))
.thenThrow(new AwsException("InternalServerException", "boom", 500));
ObjectNode props = mapper.createObjectNode();
@@ -190,7 +190,7 @@ class BedrockAgentCoreCfnProvisionerTest {
void rollbackUpdateRestoresAnInPlaceRuntimeChangeAsANewVersion() {
AgentRuntime prior = runtime("one", Map.of("K", "v"));
when(runtimes.getAgentRuntime(RUNTIME_ID, REGION)).thenReturn(prior);
when(runtimes.arn(any(), any(), eq(REGION))).thenReturn(RUNTIME_ARN);
when(runtimes.arn(any(), eq(REGION))).thenReturn(RUNTIME_ARN);
when(runtimes.getTagsByArn(REGION, RUNTIME_ARN)).thenReturn(new HashMap<>(Map.of("team", "agents")));
when(runtimes.updateAgentRuntime(eq(RUNTIME_ID), any(), any(), any(), any(), any(), any(), any(), eq(REGION)))
.thenReturn(prior);
@@ -216,7 +216,7 @@ class BedrockAgentCoreCfnProvisionerTest {
void anUnchangedRuntimeIsNeitherUpdatedNorSnapshotted() {
AgentRuntime prior = runtime("one", Map.of());
when(runtimes.getAgentRuntime(RUNTIME_ID, REGION)).thenReturn(prior);
when(runtimes.arn(any(), any(), eq(REGION))).thenReturn(RUNTIME_ARN);
when(runtimes.arn(any(), eq(REGION))).thenReturn(RUNTIME_ARN);
when(runtimes.getTagsByArn(REGION, RUNTIME_ARN)).thenReturn(new HashMap<>(Map.of("team", "agents")));
StackResource r = resource("AWS::BedrockAgentCore::Runtime");
r.setPhysicalId(RUNTIME_ID);
@@ -271,8 +271,8 @@ class BedrockAgentCoreCfnProvisionerTest {
.thenReturn(Optional.of(new BedrockAgentCoreControlService.EndpointLocation(runtime, existing)));
when(runtimes.updateEndpoint(eq(RUNTIME_ID), eq("prod"), any(), any(), anyBoolean(), eq(REGION)))
.thenReturn(existing);
when(runtimes.endpointArn(existing, REGION)).thenReturn("arn:ep");
when(runtimes.arn(any(), anyString(), eq(REGION))).thenReturn(RUNTIME_ARN);
when(runtimes.endpointArn(RUNTIME_ID, existing, REGION)).thenReturn("arn:ep");
when(runtimes.arn(any(), eq(REGION))).thenReturn(RUNTIME_ARN);
ObjectNode props = mapper.createObjectNode();
props.put("AgentRuntimeId", RUNTIME_ID);
props.put("Name", "prod");