Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ agentcore add gateway \
| `--name <name>` | Gateway name |
| `--description <desc>` | Gateway description |
| `--runtimes <names>` | Comma-separated runtime names to expose through this gateway |
| `--authorizer-type <type>` | `NONE` (default) or `CUSTOM_JWT` |
| `--authorizer-type <type>` | `NONE` (default), `AWS_IAM`, or `CUSTOM_JWT` |
| `--discovery-url <url>` | OIDC discovery URL (required for CUSTOM_JWT) |
| `--allowed-audience <values>` | Comma-separated allowed audiences (required for CUSTOM_JWT) |
| `--allowed-clients <values>` | Comma-separated allowed client IDs (required for CUSTOM_JWT) |
Expand Down
6 changes: 6 additions & 0 deletions src/cli/commands/add/__tests__/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ const validGatewayOptionsNone: AddGatewayOptions = {
authorizerType: 'NONE',
};

const validGatewayOptionsIam: AddGatewayOptions = {
name: 'test-gateway',
authorizerType: 'AWS_IAM',
};

const validGatewayOptionsJwt: AddGatewayOptions = {
name: 'test-gateway',
authorizerType: 'CUSTOM_JWT',
Expand Down Expand Up @@ -343,6 +348,7 @@ describe('validate', () => {
// AC14: Valid options pass
it('passes for valid options', () => {
expect(validateAddGatewayOptions(validGatewayOptionsNone)).toEqual({ valid: true });
expect(validateAddGatewayOptions(validGatewayOptionsIam)).toEqual({ valid: true });
expect(validateAddGatewayOptions(validGatewayOptionsJwt)).toEqual({ valid: true });
});

Expand Down
9 changes: 7 additions & 2 deletions src/cli/commands/add/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ConfigIO, findConfigRoot } from '../../../lib';
import {
AgentNameSchema,
BuildTypeSchema,
GatewayAuthorizerTypeSchema,
GatewayExceptionLevelSchema,
GatewayNameSchema,
ModelProviderSchema,
Expand Down Expand Up @@ -296,8 +297,12 @@ export function validateAddGatewayOptions(options: AddGatewayOptions): Validatio
return { valid: false, error: nameResult.error.issues[0]?.message ?? 'Invalid gateway name' };
}

if (options.authorizerType && !['NONE', 'CUSTOM_JWT'].includes(options.authorizerType)) {
return { valid: false, error: 'Invalid authorizer type. Use NONE or CUSTOM_JWT' };
if (options.authorizerType) {
const result = GatewayAuthorizerTypeSchema.safeParse(options.authorizerType);
if (!result.success) {
const valid = GatewayAuthorizerTypeSchema.options.join(', ');
return { valid: false, error: `Invalid authorizer type. Use ${valid}` };
}
}

if (options.authorizerType === 'CUSTOM_JWT') {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/primitives/GatewayPrimitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class GatewayPrimitive extends BasePrimitive<AddGatewayOptions, Removable
.option('--name <name>', 'Gateway name [non-interactive]')
.option('--description <desc>', 'Gateway description [non-interactive]')
.option('--runtimes <runtimes>', 'Comma-separated runtime names to expose through this gateway [non-interactive]')
.option('--authorizer-type <type>', 'Authorizer type: NONE or CUSTOM_JWT [non-interactive]')
.option('--authorizer-type <type>', 'Authorizer type: NONE, AWS_IAM, or CUSTOM_JWT [non-interactive]')
.option('--discovery-url <url>', 'OIDC discovery URL (for CUSTOM_JWT) [non-interactive]')
.option('--allowed-audience <audience>', 'Comma-separated allowed audiences (for CUSTOM_JWT) [non-interactive]')
.option('--allowed-clients <clients>', 'Comma-separated allowed client IDs (for CUSTOM_JWT) [non-interactive]')
Expand Down
Loading