feat(project): add gateway resources - #2028
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2028 +/- ##
============================================
+ Coverage 97.24% 97.30% +0.05%
============================================
Files 396 400 +4
Lines 24019 24544 +525
============================================
+ Hits 23357 23882 +525
Misses 662 662 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dbcb3b6 to
fd627a1
Compare
fd627a1 to
41a946d
Compare
41a946d to
7753af0
Compare
| ); | ||
| if (gatewayIndex < 0) { | ||
| throw new InputValidationError( | ||
| `gateway '${input.gatewayName}' does not exist in agentCoreGateways[]`, |
There was a problem hiding this comment.
nit: does not exist in project. Please check agentCoreGateway in agentcore.json
| }; | ||
| } | ||
|
|
||
| private assertUniqueGatewayTargetName(project: Project["spec"], name: string): void { |
There was a problem hiding this comment.
Are all gateway target names required to be unique across every gateway, or must they only be unique inside a single gateway?
There was a problem hiding this comment.
This is due to a limitation with the current CDK. The name technically only has to be unique to the gateway but the L3 CDKs require them to be globally unique. This is a change we could make on the L3 CDK but for now I was just trying to make the implementaion compatible.
There was a problem hiding this comment.
I'm going to inline this function
| ), | ||
| flag( | ||
| "knowledge-base", | ||
| "project Knowledge Base name or external ten-character Knowledge Base ID", |
There was a problem hiding this comment.
add that this could only be used with bedrock-knowledge-base
| import type { Project } from "../../types"; | ||
| import type { AddProjectResourceConfig } from "../types"; | ||
|
|
||
| export const createAddGatewayTargetHandler = (config: AddProjectResourceConfig) => |
There was a problem hiding this comment.
If you check how the help looks for the old cli, you will notice that it divides based on target
Target types and their options:
http-runtime — Route to an AgentCore runtime
--runtime <name> Runtime from your project
--runtime-endpoint <name> Endpoint / version alias (optional)
mcp-server — Connect to an MCP-compatible server
--endpoint <url> Server endpoint URL
--host <host> Lambda or AgentCoreRuntime
--language <lang> Python, TypeScript, or Other
api-gateway — Connect to an Amazon API Gateway REST API
--rest-api-id <id> REST API ID
--stage <stage> Deployment stage
open-api-schema / smithy-model — Auto-derive tools from a schema
--schema <path> Schema file path or S3 URI
--schema-s3-account <id> S3 bucket owner account ID
lambda-function-arn — Connect to an AWS Lambda function
--lambda-arn <arn> Lambda function ARN
--tool-schema-file <path> Tool schema JSON file
connector — Wire a managed AWS connector (bedrock-knowledge-bases, web-search)
--connector <id> bedrock-knowledge-bases or web-search
--knowledge-base-id <id> Project KB name or 10-char external KB id (for KB connectors)
--exclude-domains <list> Comma-separated domains to exclude (for web-search connector)
passthrough — Route to an external HTTPS endpoint
--passthrough-endpoint <url> HTTPS endpoint URL
--stickiness-identifier <expr> Session routing expression (optional)
--stickiness-timeout <seconds> Sticky session timeout in seconds (optional)
Auth (--outbound-auth <type>, --credential-name <name>) — valid types per target:
mcp-server oauth or none
lambda-function-arn oauth or none
http-runtime oauth or none
open-api-schema oauth or api-key (required)
api-gateway api-key or none
smithy-model none (uses gateway IAM role)
passthrough gateway-iam-role, oauth, or jwt-passthrough
| configurations: [{ name: "WebSearch", parameterValues: { maxResults: 10 } }], | ||
| }; | ||
| case "bedrock-knowledge-bases": | ||
| if (!knowledgeBase) { |
There was a problem hiding this comment.
Don't we do this validation at line 60?
| ), | ||
| flag("exception-level", "exception detail level: debug", z.enum(["debug"]).optional()), | ||
| flag( | ||
| "tags", |
There was a problem hiding this comment.
Check runtime and harness, we don't do SourceResolver for this.
| "restrict Target protocols to MCP; omitted allows every Target protocol", | ||
| z.enum(["mcp"]).optional(), | ||
| ), | ||
| flag( |
There was a problem hiding this comment.
nit: The description should say enable semantic search to search tools on gateway
| z.string().optional(), | ||
| ), | ||
| flag( | ||
| "policy-engine-name", |
There was a problem hiding this comment.
Should we expand this for policy engines outside of this project? What is cons of doing that?
| testIO, | ||
| } from "../../../testing"; | ||
|
|
||
| export function createGatewayProjectTestHarness(directoryPrefix: string) { |
There was a problem hiding this comment.
combine this with index.test.ts. If no one other test file is using it, it should be combine with the test file
|
|
||
| export type RemoveResourceInput = { | ||
| resourceType: ProjectResource; | ||
| resourceType: Exclude<ProjectResource, "gateway" | "gateway-target">; |
There was a problem hiding this comment.
Why are we excluding it from remove?
Is this failure related to the changes here? I don't see this failure on main. |
Summary
Adds project-based Gateway resource management:
Project-command JSON maps directly to the existing version 1
agentcore.jsonschemas:--authorizer-configurationacceptsGatewayAuthorizerConfigSchema;--target-configurationaccepts one completeAgentCoreGatewayTargetSchemaobject;--connector-configurationaccepts the same complete Target object and requirestargetType: "connector";file://, and through stdin;Scalar endpoint, Runtime, and curated Connector shortcuts construct the same
project-schema objects accepted through JSON. Connector removal is an alias over
Gateway Target removal because Connectors are stored as ordinary Targets.
Gateway protocol behavior preserves the existing schema and L3 contract:
--protocol-typepersistsprotocolType: "None"and creates an unrestricted Gateway;--protocol-type MCPpersistsprotocolType: "MCP"and creates an MCP-only Gateway;"None"is not exposed as a flag value because omission already selects it;--protocol-type MCP.The change also:
agentcore.jsonwrite;unassignedTargets[], matching the existing L3 Target-output contract.The CLI does not create or copy files referenced by Target JSON. Paths such as
schemaSource.inline.pathandlambdaFunctionArn.toolSchemaFileremain explicitin
agentcore.json.Testing
Verification on CLI head
523a5b35:bun test src --coverageoutside the restricted sandbox: 1,794 passed;bun run typecheck;bun run lint:check;bun run format:check;bun run build;Live deployment
Earlier end-to-end verification of the persisted Gateway and Target shapes used
a generated project with
@aws/agentcore-cdk@0.1.0-alpha.45:READY;initializeandtools/listreturned HTTP 200;Credential-provider authoring is owned by the separate project credentials
commands. This PR validates Gateway Target references to those project
credentials but does not create them.