Skip to content

Commit defb5ab

Browse files
committed
refactor: change --id to --arn on import runtime and memory subcommands
Users now provide the full resource ARN instead of just the ID. The runtime/memory ID is extracted from the ARN's last path segment.
1 parent 3b13a91 commit defb5ab

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/cli/commands/import/__tests__/import-runtime-handler.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('handleImportRuntime', () => {
144144
});
145145

146146
const result = await handleImportRuntime({
147-
id: 'rt-123',
147+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
148148
code: '/tmp/test-source',
149149
name: 'myagent',
150150
});
@@ -170,7 +170,7 @@ describe('handleImportRuntime', () => {
170170
});
171171

172172
const result = await handleImportRuntime({
173-
id: 'rt-123',
173+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
174174
code: '/tmp/test-source',
175175
name: 'myagent',
176176
});
@@ -195,7 +195,7 @@ describe('handleImportRuntime', () => {
195195
});
196196

197197
const result = await handleImportRuntime({
198-
id: 'rt-123',
198+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
199199
code: '/tmp/test-source',
200200
name: 'myagent',
201201
});
@@ -225,7 +225,7 @@ describe('handleImportRuntime', () => {
225225
mockCopyAgentSource.mockRejectedValue(new Error('stop here'));
226226

227227
await handleImportRuntime({
228-
id: 'rt-123',
228+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
229229
code: '/tmp/test-source',
230230
name: 'myagent',
231231
entrypoint: 'custom_app.py',
@@ -257,7 +257,7 @@ describe('handleImportRuntime', () => {
257257
mockCopyAgentSource.mockRejectedValue(new Error('stop here'));
258258

259259
await handleImportRuntime({
260-
id: 'rt-123',
260+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
261261
code: '/tmp/test-source',
262262
name: 'myagent',
263263
});
@@ -287,7 +287,7 @@ describe('handleImportRuntime', () => {
287287
});
288288

289289
const result = await handleImportRuntime({
290-
id: 'rt-123',
290+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
291291
name: 'myagent',
292292
// no code option
293293
});
@@ -315,7 +315,7 @@ describe('handleImportRuntime', () => {
315315
vi.mocked(fs.existsSync).mockReturnValue(false);
316316

317317
const result = await handleImportRuntime({
318-
id: 'rt-123',
318+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
319319
code: '/nonexistent/path',
320320
name: 'myagent',
321321
});
@@ -347,7 +347,7 @@ describe('handleImportRuntime', () => {
347347
});
348348

349349
const result = await handleImportRuntime({
350-
id: 'rt-123',
350+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123:runtime/rt-123',
351351
code: '/tmp/test-source',
352352
name: 'myagent',
353353
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export async function handleImportMemory(options: ImportResourceOptions): Promis
8888
logger.startStep('Fetch memory from AWS');
8989
let memoryId: string;
9090

91-
if (options.id) {
92-
memoryId = options.id;
91+
if (options.arn) {
92+
memoryId = options.arn.split('/').pop()!;
9393
} else {
9494
// List memories and show to user
9595
onProgress('Listing memories in your account...');
@@ -116,7 +116,7 @@ export async function handleImportMemory(options: ImportResourceOptions): Promis
116116
}
117117
console.log('');
118118

119-
const error = 'Multiple memories found. Use --id <memoryId> to specify which memory to import.';
119+
const error = 'Multiple memories found. Use --arn <memoryArn> to specify which memory to import.';
120120
logger.endStep('error', error);
121121
logger.finalize(false);
122122
return { success: false, error, resourceType: 'memory', resourceName: '', logPath: logger.getRelativeLogPath() };
@@ -359,7 +359,7 @@ export function registerImportMemory(importCmd: Command): void {
359359
importCmd
360360
.command('memory')
361361
.description('Import an existing AgentCore Memory from your AWS account')
362-
.option('--id <memoryId>', 'Memory ID to import')
362+
.option('--arn <memoryArn>', 'Memory ARN to import')
363363
.option('--target <target>', 'Deployment target name')
364364
.option('--name <name>', 'Local name for the imported memory')
365365
.option('-y, --yes', 'Auto-confirm prompts')

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ export async function handleImportRuntime(options: ImportResourceOptions): Promi
104104
logger.startStep('Fetch runtime from AWS');
105105
let runtimeId: string;
106106

107-
if (options.id) {
108-
runtimeId = options.id;
107+
if (options.arn) {
108+
runtimeId = options.arn.split('/').pop()!;
109109
} else {
110110
// List runtimes and let user pick
111111
onProgress('Listing runtimes in your account...');
@@ -132,8 +132,8 @@ export async function handleImportRuntime(options: ImportResourceOptions): Promi
132132
}
133133
console.log('');
134134

135-
// For non-interactive mode, require --id
136-
const error = 'Multiple runtimes found. Use --id <runtimeId> to specify which runtime to import.';
135+
// For non-interactive mode, require --arn
136+
const error = 'Multiple runtimes found. Use --arn <runtimeArn> to specify which runtime to import.';
137137
logger.endStep('error', error);
138138
logger.finalize(false);
139139
return { success: false, error, resourceType: 'runtime', resourceName: '', logPath: logger.getRelativeLogPath() };
@@ -459,7 +459,7 @@ export function registerImportRuntime(importCmd: Command): void {
459459
importCmd
460460
.command('runtime')
461461
.description('Import an existing AgentCore Runtime from your AWS account')
462-
.option('--id <runtimeId>', 'Runtime ID to import')
462+
.option('--arn <runtimeArn>', 'Runtime ARN to import')
463463
.requiredOption(
464464
'--code <path>',
465465
'Path to the directory containing the entrypoint file (e.g., the folder with main.py)'

src/cli/commands/import/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export interface ImportResourceResult {
101101
* Options shared across import subcommands.
102102
*/
103103
export interface ImportResourceOptions {
104-
id?: string;
104+
arn?: string;
105105
code?: string;
106106
target?: string;
107107
name?: string;

0 commit comments

Comments
 (0)