Skip to content

Commit e159158

Browse files
committed
feat(import): capture tags during memory import
Fetch tags via ListTagsForResource API and include them in the imported memory config. Tags already flow through the CLI schema and CDK construct, they just weren't being read from the API during import.
1 parent c7ebd03 commit e159158

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/cli/aws/agentcore-control.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ListAgentRuntimesCommand,
99
ListEvaluatorsCommand,
1010
ListMemoriesCommand,
11+
ListTagsForResourceCommand,
1112
UpdateOnlineEvaluationConfigCommand,
1213
} from '@aws-sdk/client-bedrock-agentcore-control';
1314

@@ -258,6 +259,7 @@ export interface MemoryDetail {
258259
namespaces?: string[];
259260
reflectionNamespaces?: string[];
260261
}[];
262+
tags?: Record<string, string>;
261263
}
262264

263265
/**
@@ -293,13 +295,25 @@ export async function getMemoryDetail(options: GetMemoryOptions): Promise<Memory
293295
throw new Error(`Memory ${options.memoryId} is missing required field: eventExpiryDuration`);
294296
}
295297

298+
// Fetch tags via separate API call
299+
let tags: Record<string, string> | undefined;
300+
try {
301+
const tagsResponse = await client.send(new ListTagsForResourceCommand({ resourceArn: memory.arn }));
302+
if (tagsResponse.tags && Object.keys(tagsResponse.tags).length > 0) {
303+
tags = tagsResponse.tags;
304+
}
305+
} catch {
306+
// Tags are optional — continue without them if the call fails
307+
}
308+
296309
return {
297310
memoryId: memory.id,
298311
memoryArn: memory.arn,
299312
name: memory.name,
300313
status: memory.status ?? 'UNKNOWN',
301314
description: memory.description,
302315
eventExpiryDuration: memory.eventExpiryDuration,
316+
tags,
303317
strategies: (memory.strategies ?? []).map(s => {
304318
if (!s.type) {
305319
throw new Error(`Memory ${options.memoryId} has a strategy with missing required field: type`);

src/cli/commands/import/import-memory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function toMemorySpec(memory: MemoryDetail, localName: string): Memory {
6666
name: localName,
6767
eventExpiryDuration: Math.max(7, Math.min(365, memory.eventExpiryDuration)),
6868
strategies,
69+
...(memory.tags && Object.keys(memory.tags).length > 0 && { tags: memory.tags }),
6970
};
7071
}
7172

0 commit comments

Comments
 (0)