feat: add Lambda interceptors for AgentCore gateways#1330
Open
aidandaly24 wants to merge 11 commits into
Open
Conversation
Contributor
Package TarballHow to installgh release download pr-1330-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.17.0.tgz |
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
a2daa82 to
dc2fe62
Compare
Contributor
|
Claude Security Review: the review run failed before completing. See the run for details. |
Contributor
|
Claude Security Review: the review run failed before completing. See the run for details. |
Contributor
|
Claude Security Review: the review run failed before completing. See the run for details. |
Mirror the CDK schema change: AgentCoreProjectSpecSchema.interceptors is now `.optional()` (matching the `datasets` convention) instead of `.default([])`, so an agentcore.json that doesn't use interceptors stays sparse across CLI round-trips. Consumer follow-through for the now-optional field: - InterceptorPrimitive: guard every project.interceptors access with `??= []` (mutating paths) or `?? []` (read-only paths). - AddScreen: add 'interceptor' to the AddResourceType union (the BASE_ADD_RESOURCES entry referenced a union member that the rebased upstream type definition didn't include). The schema-level superRefine cross-field checks (unknown gateway, max-2 cardinality, duplicate names) already guard with `?? []`. All 70 interceptor unit tests pass; tsc/lint/format clean.
Three test files unrelated to interceptors were swept into the feature commit by an editor autofix: - import-gateway-targets.test.ts (resolved during rebase by taking main's aws#1437 rewrite) - import-gateway-spec.test.ts (restored: main keeps the eslint-disable guarding the (gw as any) cast; dropping it would fail lint) - resolve-ui-dist-dir.test.ts (restored: main keeps the split node:fs imports) None relate to Lambda interceptors; reverting to match origin/main.
c0b9ce8 to
700bc32
Compare
The lockfile was regenerated during rebase to add @aws-sdk/client-lambda alongside main's new @aws-sdk/client-efs / client-s3files deps; npm's output formatting differs from prettier, failing the format CI check. No dependency changes — formatting only.
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
…tional-policies Completes the interceptor feature surface so it matches every other GA primitive — no more TUI dead-ends. Add wizard (src/cli/tui/screens/interceptor/): - Full interactive add flow: name → gateway → interception points → mode (managed | external) → [managed: template → runtime → advanced] → confirm. - Advanced settings page (multi-select, mirrors agent BYO computeByoSteps): Lambda timeout, additional IAM policies, pass request headers — each injects its sub-step only when selected; unselected use defaults. - computeInterceptorSteps() is a pure, unit-tested step machine; honors the dynamic-step closure gotcha (explicit setStep on mode/advanced change). - Interception points persist in canonical REQUEST,RESPONSE order regardless of toggle order, for diff-stable agentcore.json. - lambda-arn input validates against the schema pattern + 170-char cap. Remove wizard: - RemoveInterceptorScreen + RemoveFlow select-interceptor path mirror the evaluator flow: select → previewRemove (shows dir + JSON diff) → confirm. - Interceptor is now a first-class entry in both the add and remove pickers. status visibility: - agentcore status renders an Interceptors section (deployed / local-only / pending-removal) with mode + interception points, via the generic diffResourceSet over mcp.interceptors. --additional-policies: - Wired the flag end to end in the add command (schema + CDK already supported it); comma-parsed, rejected in external mode, written sparsely (empty/whitespace-only input omits the field). mask.ts: corrected the stale 'Used by' comment to list only real call sites. Verified via tui-harness drive-through (add + remove end to end, on-disk agentcore.json + scaffolding asserted) plus typecheck, lint, and 4622/4623 unit tests (1 pre-existing unrelated LogsScreen timing flake that passes in isolation).
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
…ng footgun passRequestHeaders controls whether the gateway forwards the caller's request headers (incl. the Authorization token) to the interceptor. It was effectively undocumented and carried a silent footgun: disabling it on a header-reading interceptor (e.g. the jwt-scope-authorizer template) makes the handler receive empty headers and silently no-op, with no runtime error. - preflight: warn at deploy/validate when a managed interceptor has passRequestHeaders disabled AND its handler source reads request headers. The spec doesn't record which template was used, so the check greps the handler file rather than keying off template identity. - docs/interceptors.md: add a config-fields table and a prominent passRequestHeaders section explaining the field, the security consideration, and the header-reading-template coupling. - CLI --no-pass-request-headers help text now states the consequence. Does NOT change the default (still true) — whether the default should flip to match the service contract is a separate question pending service-team input.
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds end-to-end support for Lambda interceptors at gateway REQUEST and RESPONSE points: a new
InterceptorPrimitive, three vended templates (pass-through,jwt-scope-authorizer,tools-list-filter) for both Python and Node.js, deploy-side preflight, andlogs interceptor/invoke interceptorverbs.Primitive surface
Schema
Deploy
Templates
Bug fixes
Out of scope (P0)
The following were deliberately excluded from this PR. None are bugs — flagged here so reviewers don't ask "where is X":
Related Issue
Closes #
Documentation PR
Type of Change
Testing
Additionally:
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.