@aws/agentcore-cdk 0.1.0-alpha.5 → 0.1.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -12
- package/dist/cdk/constants.d.ts +8 -0
- package/dist/cdk/constants.d.ts.map +1 -1
- package/dist/cdk/constants.js +27 -1
- package/dist/cdk/constants.js.map +1 -1
- package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.d.ts +21 -4
- package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.d.ts.map +1 -1
- package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.js +69 -6
- package/dist/cdk/constructs/bundling/container/ContainerSourceAsset.js.map +1 -1
- package/dist/cdk/constructs/bundling/container/ContainerSourceAssetFromPath.d.ts +17 -0
- package/dist/cdk/constructs/bundling/container/ContainerSourceAssetFromPath.d.ts.map +1 -0
- package/dist/cdk/constructs/bundling/container/ContainerSourceAssetFromPath.js +20 -0
- package/dist/cdk/constructs/bundling/container/ContainerSourceAssetFromPath.js.map +1 -0
- package/dist/cdk/constructs/bundling/container/index.d.ts +1 -0
- package/dist/cdk/constructs/bundling/container/index.d.ts.map +1 -1
- package/dist/cdk/constructs/bundling/container/index.js +3 -1
- package/dist/cdk/constructs/bundling/container/index.js.map +1 -1
- package/dist/cdk/constructs/bundling/index.d.ts +2 -0
- package/dist/cdk/constructs/bundling/index.d.ts.map +1 -1
- package/dist/cdk/constructs/bundling/index.js +6 -2
- package/dist/cdk/constructs/bundling/index.js.map +1 -1
- package/dist/cdk/constructs/bundling/zip/NodeBundledCodeZipAsset.d.ts +7 -0
- package/dist/cdk/constructs/bundling/zip/NodeBundledCodeZipAsset.d.ts.map +1 -0
- package/dist/cdk/constructs/bundling/zip/NodeBundledCodeZipAsset.js +30 -0
- package/dist/cdk/constructs/bundling/zip/NodeBundledCodeZipAsset.js.map +1 -0
- package/dist/cdk/constructs/bundling/zip/index.d.ts +1 -0
- package/dist/cdk/constructs/bundling/zip/index.d.ts.map +1 -1
- package/dist/cdk/constructs/bundling/zip/index.js +3 -1
- package/dist/cdk/constructs/bundling/zip/index.js.map +1 -1
- package/dist/cdk/constructs/components/base-props.d.ts +2 -0
- package/dist/cdk/constructs/components/base-props.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts +35 -8
- package/dist/cdk/constructs/components/container/ContainerBuildProject.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerBuildProject.js +117 -13
- package/dist/cdk/constructs/components/container/ContainerBuildProject.js.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts +23 -5
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.js +45 -7
- package/dist/cdk/constructs/components/container/ContainerImageBuilder.js.map +1 -1
- package/dist/cdk/constructs/components/container/container-build-handler.d.ts +4 -1
- package/dist/cdk/constructs/components/container/container-build-handler.d.ts.map +1 -1
- package/dist/cdk/constructs/components/container/container-build-handler.js +16 -3
- package/dist/cdk/constructs/components/container/container-build-handler.js.map +1 -1
- package/dist/cdk/constructs/components/mcp/Gateway.d.ts +71 -0
- package/dist/cdk/constructs/components/mcp/Gateway.d.ts.map +1 -0
- package/dist/cdk/constructs/components/mcp/Gateway.js +976 -0
- package/dist/cdk/constructs/components/mcp/Gateway.js.map +1 -0
- package/dist/cdk/constructs/components/mcp/McpLambdaCompute.js +2 -2
- package/dist/cdk/constructs/components/mcp/McpLambdaCompute.js.map +1 -1
- package/dist/cdk/constructs/components/mcp/McpRuntimeCompute.js +1 -1
- package/dist/cdk/constructs/components/mcp/McpRuntimeCompute.js.map +1 -1
- package/dist/cdk/constructs/components/mcp/connector-defaults.d.ts +20 -0
- package/dist/cdk/constructs/components/mcp/connector-defaults.d.ts.map +1 -0
- package/dist/cdk/constructs/components/mcp/connector-defaults.js +16 -0
- package/dist/cdk/constructs/components/mcp/connector-defaults.js.map +1 -0
- package/dist/cdk/constructs/components/mcp/index.d.ts +1 -1
- package/dist/cdk/constructs/components/mcp/index.d.ts.map +1 -1
- package/dist/cdk/constructs/components/mcp/index.js +3 -3
- package/dist/cdk/constructs/components/mcp/index.js.map +1 -1
- package/dist/cdk/constructs/components/mcp/mcp-utils.d.ts +1 -1
- package/dist/cdk/constructs/components/mcp/mcp-utils.d.ts.map +1 -1
- package/dist/cdk/constructs/components/mcp/mcp-utils.js +2 -2
- package/dist/cdk/constructs/components/mcp/mcp-utils.js.map +1 -1
- package/dist/cdk/constructs/components/primitives/BasePrimitiveConstruct.d.ts +51 -0
- package/dist/cdk/constructs/components/primitives/BasePrimitiveConstruct.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/BasePrimitiveConstruct.js +54 -0
- package/dist/cdk/constructs/components/primitives/BasePrimitiveConstruct.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/AgentCoreCapacityProvider.d.ts +45 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/AgentCoreCapacityProvider.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/AgentCoreCapacityProvider.js +179 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/AgentCoreCapacityProvider.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/index.d.ts +2 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/index.js +6 -0
- package/dist/cdk/constructs/components/primitives/capacity-provider/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/AgentCoreConfigBundle.d.ts +36 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/AgentCoreConfigBundle.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/AgentCoreConfigBundle.js +66 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/AgentCoreConfigBundle.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/index.d.ts +3 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/index.js +6 -0
- package/dist/cdk/constructs/components/primitives/config-bundle/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/dataset/AgentCoreDataset.d.ts +36 -0
- package/dist/cdk/constructs/components/primitives/dataset/AgentCoreDataset.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/dataset/AgentCoreDataset.js +91 -0
- package/dist/cdk/constructs/components/primitives/dataset/AgentCoreDataset.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/dataset/index.d.ts +2 -0
- package/dist/cdk/constructs/components/primitives/dataset/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/dataset/index.js +6 -0
- package/dist/cdk/constructs/components/primitives/dataset/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreEvaluator.d.ts +50 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreEvaluator.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreEvaluator.js +213 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreEvaluator.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreOnlineEvaluationConfig.d.ts +28 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreOnlineEvaluationConfig.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreOnlineEvaluationConfig.js +238 -0
- package/dist/cdk/constructs/components/primitives/evaluator/AgentCoreOnlineEvaluationConfig.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/evaluator/index.d.ts +3 -0
- package/dist/cdk/constructs/components/primitives/evaluator/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/evaluator/index.js +8 -0
- package/dist/cdk/constructs/components/primitives/evaluator/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarness.d.ts +58 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarness.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarness.js +79 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarness.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarnessRole.d.ts +65 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarnessRole.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarnessRole.js +435 -0
- package/dist/cdk/constructs/components/primitives/harness/AgentCoreHarnessRole.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/__tests__/AgentCoreHarnessRole.test.d.ts +2 -0
- package/dist/cdk/constructs/components/primitives/harness/__tests__/AgentCoreHarnessRole.test.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/__tests__/AgentCoreHarnessRole.test.js +182 -0
- package/dist/cdk/constructs/components/primitives/harness/__tests__/AgentCoreHarnessRole.test.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/harness-cfn-mapping.d.ts +47 -0
- package/dist/cdk/constructs/components/primitives/harness/harness-cfn-mapping.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/harness-cfn-mapping.js +391 -0
- package/dist/cdk/constructs/components/primitives/harness/harness-cfn-mapping.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/index.d.ts +3 -0
- package/dist/cdk/constructs/components/primitives/harness/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/harness/index.js +8 -0
- package/dist/cdk/constructs/components/primitives/harness/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/index.d.ts +10 -0
- package/dist/cdk/constructs/components/primitives/index.d.ts.map +1 -1
- package/dist/cdk/constructs/components/primitives/index.js +23 -1
- package/dist/cdk/constructs/components/primitives/index.js.map +1 -1
- package/dist/cdk/constructs/components/primitives/knowledge-base/AgentCoreKnowledgeBase.d.ts +69 -0
- package/dist/cdk/constructs/components/primitives/knowledge-base/AgentCoreKnowledgeBase.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/knowledge-base/AgentCoreKnowledgeBase.js +292 -0
- package/dist/cdk/constructs/components/primitives/knowledge-base/AgentCoreKnowledgeBase.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/knowledge-base/index.d.ts +2 -0
- package/dist/cdk/constructs/components/primitives/knowledge-base/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/knowledge-base/index.js +6 -0
- package/dist/cdk/constructs/components/primitives/knowledge-base/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/memory/AgentCoreMemory.d.ts +15 -4
- package/dist/cdk/constructs/components/primitives/memory/AgentCoreMemory.d.ts.map +1 -1
- package/dist/cdk/constructs/components/primitives/memory/AgentCoreMemory.js +96 -63
- package/dist/cdk/constructs/components/primitives/memory/AgentCoreMemory.js.map +1 -1
- package/dist/cdk/constructs/components/primitives/memory/__tests__/AgentCoreMemory.test.d.ts +2 -0
- package/dist/cdk/constructs/components/primitives/memory/__tests__/AgentCoreMemory.test.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/memory/__tests__/AgentCoreMemory.test.js +146 -0
- package/dist/cdk/constructs/components/primitives/memory/__tests__/AgentCoreMemory.test.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/memory/memory-actions.d.ts +15 -0
- package/dist/cdk/constructs/components/primitives/memory/memory-actions.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/memory/memory-actions.js +32 -0
- package/dist/cdk/constructs/components/primitives/memory/memory-actions.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentConnector.d.ts +41 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentConnector.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentConnector.js +64 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentConnector.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentManager.d.ts +38 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentManager.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentManager.js +111 -0
- package/dist/cdk/constructs/components/primitives/payment/AgentCorePaymentManager.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/payment/index.d.ts +3 -0
- package/dist/cdk/constructs/components/primitives/payment/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/payment/index.js +8 -0
- package/dist/cdk/constructs/components/primitives/payment/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/policy/AgentCorePolicyEngine.d.ts +28 -0
- package/dist/cdk/constructs/components/primitives/policy/AgentCorePolicyEngine.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/policy/AgentCorePolicyEngine.js +75 -0
- package/dist/cdk/constructs/components/primitives/policy/AgentCorePolicyEngine.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/policy/index.d.ts +2 -0
- package/dist/cdk/constructs/components/primitives/policy/index.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/policy/index.js +6 -0
- package/dist/cdk/constructs/components/primitives/policy/index.js.map +1 -0
- package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.d.ts +43 -2
- package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.d.ts.map +1 -1
- package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.js +337 -80
- package/dist/cdk/constructs/components/primitives/runtime/AgentCoreRuntime.js.map +1 -1
- package/dist/cdk/constructs/components/primitives/runtime/__tests__/AgentCoreRuntime.test.d.ts +2 -0
- package/dist/cdk/constructs/components/primitives/runtime/__tests__/AgentCoreRuntime.test.d.ts.map +1 -0
- package/dist/cdk/constructs/components/primitives/runtime/__tests__/AgentCoreRuntime.test.js +113 -0
- package/dist/cdk/constructs/components/primitives/runtime/__tests__/AgentCoreRuntime.test.js.map +1 -0
- package/dist/cdk/constructs/components/shared/__tests__/build-authorizer-config.test.d.ts +2 -0
- package/dist/cdk/constructs/components/shared/__tests__/build-authorizer-config.test.d.ts.map +1 -0
- package/dist/cdk/constructs/components/shared/__tests__/build-authorizer-config.test.js +99 -0
- package/dist/cdk/constructs/components/shared/__tests__/build-authorizer-config.test.js.map +1 -0
- package/dist/cdk/constructs/components/shared/build-authorizer-config.d.ts +28 -0
- package/dist/cdk/constructs/components/shared/build-authorizer-config.d.ts.map +1 -0
- package/dist/cdk/constructs/components/shared/build-authorizer-config.js +39 -0
- package/dist/cdk/constructs/components/shared/build-authorizer-config.js.map +1 -0
- package/dist/cdk/constructs/components/shared/load-additional-policies.d.ts +18 -0
- package/dist/cdk/constructs/components/shared/load-additional-policies.d.ts.map +1 -0
- package/dist/cdk/constructs/components/shared/load-additional-policies.js +51 -0
- package/dist/cdk/constructs/components/shared/load-additional-policies.js.map +1 -0
- package/dist/cdk/constructs/connections/wire-connections.d.ts +24 -0
- package/dist/cdk/constructs/connections/wire-connections.d.ts.map +1 -0
- package/dist/cdk/constructs/connections/wire-connections.js +218 -0
- package/dist/cdk/constructs/connections/wire-connections.js.map +1 -0
- package/dist/cdk/constructs/index.d.ts +7 -3
- package/dist/cdk/constructs/index.d.ts.map +1 -1
- package/dist/cdk/constructs/index.js +22 -1
- package/dist/cdk/constructs/index.js.map +1 -1
- package/dist/cdk/constructs/l3/AgentCoreApplication.d.ts +149 -2
- package/dist/cdk/constructs/l3/AgentCoreApplication.d.ts.map +1 -1
- package/dist/cdk/constructs/l3/AgentCoreApplication.js +623 -10
- package/dist/cdk/constructs/l3/AgentCoreApplication.js.map +1 -1
- package/dist/cdk/constructs/l3/AgentCoreHarnessEnvironment.d.ts +38 -0
- package/dist/cdk/constructs/l3/AgentCoreHarnessEnvironment.d.ts.map +1 -0
- package/dist/cdk/constructs/l3/AgentCoreHarnessEnvironment.js +92 -0
- package/dist/cdk/constructs/l3/AgentCoreHarnessEnvironment.js.map +1 -0
- package/dist/cdk/constructs/l3/AgentCoreMcp.d.ts +9 -1
- package/dist/cdk/constructs/l3/AgentCoreMcp.d.ts.map +1 -1
- package/dist/cdk/constructs/l3/AgentCoreMcp.js +95 -17
- package/dist/cdk/constructs/l3/AgentCoreMcp.js.map +1 -1
- package/dist/cdk/constructs/l3/AgentCorePayments.d.ts +21 -0
- package/dist/cdk/constructs/l3/AgentCorePayments.d.ts.map +1 -0
- package/dist/cdk/constructs/l3/AgentCorePayments.js +149 -0
- package/dist/cdk/constructs/l3/AgentCorePayments.js.map +1 -0
- package/dist/cdk/constructs/l3/AgentEnvironment.d.ts +14 -0
- package/dist/cdk/constructs/l3/AgentEnvironment.d.ts.map +1 -1
- package/dist/cdk/constructs/l3/AgentEnvironment.js +55 -4
- package/dist/cdk/constructs/l3/AgentEnvironment.js.map +1 -1
- package/dist/cdk/constructs/l3/index.d.ts +3 -1
- package/dist/cdk/constructs/l3/index.d.ts.map +1 -1
- package/dist/cdk/constructs/l3/index.js +5 -1
- package/dist/cdk/constructs/l3/index.js.map +1 -1
- package/dist/cdk/index.d.ts +1 -1
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +16 -1
- package/dist/cdk/index.js.map +1 -1
- package/dist/cdk/utils/__tests__/tags.test.d.ts +2 -0
- package/dist/cdk/utils/__tests__/tags.test.d.ts.map +1 -0
- package/dist/cdk/utils/__tests__/tags.test.js +57 -0
- package/dist/cdk/utils/__tests__/tags.test.js.map +1 -0
- package/dist/cdk/utils/tags.d.ts +11 -0
- package/dist/cdk/utils/tags.d.ts.map +1 -0
- package/dist/cdk/utils/tags.js +22 -0
- package/dist/cdk/utils/tags.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -0
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +2 -1
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/errors/config.js +1 -1
- package/dist/lib/errors/config.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/packaging/helpers.d.ts +19 -0
- package/dist/lib/packaging/helpers.d.ts.map +1 -1
- package/dist/lib/packaging/helpers.js +78 -21
- package/dist/lib/packaging/helpers.js.map +1 -1
- package/dist/lib/packaging/index.d.ts +3 -7
- package/dist/lib/packaging/index.d.ts.map +1 -1
- package/dist/lib/packaging/index.js +14 -11
- package/dist/lib/packaging/index.js.map +1 -1
- package/dist/lib/packaging/node.d.ts +6 -0
- package/dist/lib/packaging/node.d.ts.map +1 -0
- package/dist/lib/packaging/node.js +106 -0
- package/dist/lib/packaging/node.js.map +1 -0
- package/dist/lib/packaging/types/packaging.d.ts +2 -0
- package/dist/lib/packaging/types/packaging.d.ts.map +1 -1
- package/dist/lib/packaging/uv.d.ts.map +1 -1
- package/dist/lib/packaging/uv.js +1 -1
- package/dist/lib/packaging/uv.js.map +1 -1
- package/dist/lib/schemas/io/config-io.d.ts +6 -3
- package/dist/lib/schemas/io/config-io.d.ts.map +1 -1
- package/dist/lib/schemas/io/config-io.js +19 -11
- package/dist/lib/schemas/io/config-io.js.map +1 -1
- package/dist/schema/constants.d.ts +30 -0
- package/dist/schema/constants.d.ts.map +1 -1
- package/dist/schema/constants.js +58 -4
- package/dist/schema/constants.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +265 -6
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +414 -17
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +1105 -22
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/agentcore-project.js +335 -11
- package/dist/schema/schemas/agentcore-project.js.map +1 -1
- package/dist/schema/schemas/auth.d.ts +318 -0
- package/dist/schema/schemas/auth.d.ts.map +1 -0
- package/dist/schema/schemas/auth.js +238 -0
- package/dist/schema/schemas/auth.js.map +1 -0
- package/dist/schema/schemas/aws-targets.d.ts +39 -0
- package/dist/schema/schemas/aws-targets.d.ts.map +1 -1
- package/dist/schema/schemas/aws-targets.js +14 -0
- package/dist/schema/schemas/aws-targets.js.map +1 -1
- package/dist/schema/schemas/connections.d.ts +183 -0
- package/dist/schema/schemas/connections.d.ts.map +1 -0
- package/dist/schema/schemas/connections.js +176 -0
- package/dist/schema/schemas/connections.js.map +1 -0
- package/dist/schema/schemas/deployed-state.d.ts +224 -16
- package/dist/schema/schemas/deployed-state.d.ts.map +1 -1
- package/dist/schema/schemas/deployed-state.js +52 -4
- package/dist/schema/schemas/deployed-state.js.map +1 -1
- package/dist/schema/schemas/index.d.ts +2 -0
- package/dist/schema/schemas/index.d.ts.map +1 -1
- package/dist/schema/schemas/index.js +2 -0
- package/dist/schema/schemas/index.js.map +1 -1
- package/dist/schema/schemas/mcp.d.ts +645 -32
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +567 -44
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/dist/schema/schemas/primitives/capacity-provider.d.ts +239 -0
- package/dist/schema/schemas/primitives/capacity-provider.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/capacity-provider.js +220 -0
- package/dist/schema/schemas/primitives/capacity-provider.js.map +1 -0
- package/dist/schema/schemas/primitives/config-bundle.d.ts +31 -0
- package/dist/schema/schemas/primitives/config-bundle.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/config-bundle.js +41 -0
- package/dist/schema/schemas/primitives/config-bundle.js.map +1 -0
- package/dist/schema/schemas/primitives/dataset.d.ts +53 -0
- package/dist/schema/schemas/primitives/dataset.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/dataset.js +65 -0
- package/dist/schema/schemas/primitives/dataset.js.map +1 -0
- package/dist/schema/schemas/primitives/evaluator.d.ts +113 -0
- package/dist/schema/schemas/primitives/evaluator.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/evaluator.js +75 -0
- package/dist/schema/schemas/primitives/evaluator.js.map +1 -0
- package/dist/schema/schemas/primitives/harness.d.ts +649 -0
- package/dist/schema/schemas/primitives/harness.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/harness.js +596 -0
- package/dist/schema/schemas/primitives/harness.js.map +1 -0
- package/dist/schema/schemas/primitives/index.d.ts +18 -2
- package/dist/schema/schemas/primitives/index.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/index.js +80 -1
- package/dist/schema/schemas/primitives/index.js.map +1 -1
- package/dist/schema/schemas/primitives/knowledge-base.d.ts +103 -0
- package/dist/schema/schemas/primitives/knowledge-base.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/knowledge-base.js +98 -0
- package/dist/schema/schemas/primitives/knowledge-base.js.map +1 -0
- package/dist/schema/schemas/primitives/memory.d.ts +33 -2
- package/dist/schema/schemas/primitives/memory.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/memory.js +33 -3
- package/dist/schema/schemas/primitives/memory.js.map +1 -1
- package/dist/schema/schemas/primitives/online-evaluation-config.d.ts +32 -0
- package/dist/schema/schemas/primitives/online-evaluation-config.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/online-evaluation-config.js +66 -0
- package/dist/schema/schemas/primitives/online-evaluation-config.js.map +1 -0
- package/dist/schema/schemas/primitives/policy.d.ts +62 -0
- package/dist/schema/schemas/primitives/policy.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/policy.js +64 -0
- package/dist/schema/schemas/primitives/policy.js.map +1 -0
- package/dist/schema/schemas/primitives/tags.d.ts +6 -0
- package/dist/schema/schemas/primitives/tags.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/tags.js +20 -0
- package/dist/schema/schemas/primitives/tags.js.map +1 -0
- package/package.json +22 -5
- package/dist/cdk/constructs/components/mcp/McpGateway.d.ts +0 -49
- package/dist/cdk/constructs/components/mcp/McpGateway.d.ts.map +0 -1
- package/dist/cdk/constructs/components/mcp/McpGateway.js +0 -288
- package/dist/cdk/constructs/components/mcp/McpGateway.js.map +0 -1
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Gateway = void 0;
|
|
37
|
+
const lib_1 = require("../../../../lib");
|
|
38
|
+
const schema_1 = require("../../../../schema");
|
|
39
|
+
const constants_1 = require("../../../constants");
|
|
40
|
+
const logical_ids_1 = require("../../../logical-ids");
|
|
41
|
+
const tags_1 = require("../../../utils/tags");
|
|
42
|
+
const build_authorizer_config_1 = require("../shared/build-authorizer-config");
|
|
43
|
+
const McpLambdaCompute_1 = require("./McpLambdaCompute");
|
|
44
|
+
const McpRuntimeCompute_1 = require("./McpRuntimeCompute");
|
|
45
|
+
const connector_defaults_1 = require("./connector-defaults");
|
|
46
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
47
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
48
|
+
const aws_s3_assets_1 = require("aws-cdk-lib/aws-s3-assets");
|
|
49
|
+
const constructs_1 = require("constructs");
|
|
50
|
+
const path_1 = require("path");
|
|
51
|
+
/**
|
|
52
|
+
* Creates an MCP Gateway with its associated targets and compute.
|
|
53
|
+
*
|
|
54
|
+
* This component orchestrates:
|
|
55
|
+
* - CfnGateway resource creation with optional JWT authorization
|
|
56
|
+
* - Gateway IAM role
|
|
57
|
+
* - Gateway targets (Lambda or AgentCoreRuntime backed)
|
|
58
|
+
* - Proper IAM grants between gateway and compute
|
|
59
|
+
*/
|
|
60
|
+
class Gateway extends constructs_1.Construct {
|
|
61
|
+
cfnGateway;
|
|
62
|
+
role;
|
|
63
|
+
runtimes = new Map();
|
|
64
|
+
lambdaFunctions = new Map();
|
|
65
|
+
gatewayTargets = new Map();
|
|
66
|
+
credentials;
|
|
67
|
+
props;
|
|
68
|
+
knowledgeBases;
|
|
69
|
+
constructor(scope, id, props) {
|
|
70
|
+
super(scope, id);
|
|
71
|
+
this.props = props;
|
|
72
|
+
this.credentials = props.credentials;
|
|
73
|
+
this.knowledgeBases = props.knowledgeBases;
|
|
74
|
+
const { gateway, projectName, configRoot } = props;
|
|
75
|
+
// Use imported execution role if provided (e.g. during gateway import),
|
|
76
|
+
// otherwise create a new IAM role for the gateway.
|
|
77
|
+
if (gateway.executionRoleArn) {
|
|
78
|
+
this.role = aws_cdk_lib_1.aws_iam.Role.fromRoleArn(this, 'Role', gateway.executionRoleArn, { mutable: false });
|
|
79
|
+
cdk.Annotations.of(this).addWarning(`Gateway "${gateway.name}" uses an imported execution role. CDK cannot attach policies to it. ` +
|
|
80
|
+
'Ensure the role carries: bedrock-agentcore:GetPolicyEngine/CheckAuthorizePermissions/AuthorizeAction/' +
|
|
81
|
+
'PartiallyAuthorizeActions (policy engine), GetResourceOauth2Token/GetWorkloadAccessToken (OAuth), ' +
|
|
82
|
+
'GetApiKeyCredential/GetResourceApiKey (API key), lambda:InvokeFunction (lambdaFunctionArn), ' +
|
|
83
|
+
's3:GetObject (S3-hosted schemas), secretsmanager:GetSecretValue.');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.role = new aws_cdk_lib_1.aws_iam.Role(this, 'Role', {
|
|
87
|
+
assumedBy: new aws_cdk_lib_1.aws_iam.ServicePrincipal(constants_1.AGENTCORE_SERVICE_PRINCIPAL),
|
|
88
|
+
description: `Gateway role for: ${gateway.name}`,
|
|
89
|
+
// Policy engine permissions must be on the role at creation time because
|
|
90
|
+
// the gateway service validates GetPolicyEngine access during CreateGateway.
|
|
91
|
+
// Uses gateway/* wildcard because the gateway ARN isn't known yet (circular
|
|
92
|
+
// dependency: role must exist before gateway, but gateway ARN comes from gateway).
|
|
93
|
+
...(props.policyEngine && {
|
|
94
|
+
inlinePolicies: {
|
|
95
|
+
PolicyEngineAccess: new aws_cdk_lib_1.aws_iam.PolicyDocument({
|
|
96
|
+
statements: [
|
|
97
|
+
new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
98
|
+
actions: [
|
|
99
|
+
'bedrock-agentcore:GetPolicyEngine',
|
|
100
|
+
'bedrock-agentcore:CheckAuthorizePermissions',
|
|
101
|
+
'bedrock-agentcore:AuthorizeAction',
|
|
102
|
+
'bedrock-agentcore:PartiallyAuthorizeActions',
|
|
103
|
+
],
|
|
104
|
+
resources: [
|
|
105
|
+
props.policyEngine.policyEngineArn,
|
|
106
|
+
cdk.Stack.of(scope).formatArn({
|
|
107
|
+
service: 'bedrock-agentcore',
|
|
108
|
+
resource: 'gateway',
|
|
109
|
+
resourceName: '*',
|
|
110
|
+
}),
|
|
111
|
+
],
|
|
112
|
+
}),
|
|
113
|
+
new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
114
|
+
actions: ['bedrock:InvokeGuardrailChecks'],
|
|
115
|
+
resources: ['*'],
|
|
116
|
+
}),
|
|
117
|
+
],
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Create the Gateway resource
|
|
124
|
+
// Use resourceName (set during import) if available, otherwise generate the standard name
|
|
125
|
+
const gatewayResourceName = gateway.resourceName ?? `${projectName}-${gateway.name}`;
|
|
126
|
+
const authorizerType = gateway.authorizerType ?? 'NONE';
|
|
127
|
+
// Build authorizer configuration if using CUSTOM_JWT
|
|
128
|
+
const authorizerConfiguration = authorizerType === 'CUSTOM_JWT' && gateway.authorizerConfiguration
|
|
129
|
+
? (0, build_authorizer_config_1.buildAuthorizerConfiguration)(gateway.authorizerConfiguration)
|
|
130
|
+
: undefined;
|
|
131
|
+
const mergedTags = (0, tags_1.composeTags)(props.projectTags, gateway.tags);
|
|
132
|
+
const protocolType = gateway.protocolType ?? 'MCP';
|
|
133
|
+
this.cfnGateway = new aws_cdk_lib_1.aws_bedrockagentcore.CfnGateway(this, 'Resource', {
|
|
134
|
+
authorizerType,
|
|
135
|
+
name: gatewayResourceName,
|
|
136
|
+
// CDK L1 requires protocolType as a mandatory prop. For 'None' gateways,
|
|
137
|
+
// we set MCP here then remove it via addPropertyDeletionOverride below.
|
|
138
|
+
protocolType: 'MCP',
|
|
139
|
+
roleArn: this.role.roleArn,
|
|
140
|
+
description: gateway.description ?? `Gateway for ${gatewayResourceName}`,
|
|
141
|
+
authorizerConfiguration,
|
|
142
|
+
protocolConfiguration: this.buildProtocolConfiguration(gateway),
|
|
143
|
+
exceptionLevel: gateway.exceptionLevel === 'DEBUG' ? 'DEBUG' : undefined,
|
|
144
|
+
...(mergedTags && { tags: mergedTags }),
|
|
145
|
+
});
|
|
146
|
+
if (protocolType === 'None') {
|
|
147
|
+
this.cfnGateway.addPropertyDeletionOverride('ProtocolType');
|
|
148
|
+
this.cfnGateway.addPropertyDeletionOverride('ProtocolConfiguration');
|
|
149
|
+
}
|
|
150
|
+
// Associate policy engine via property override (not yet in CfnGatewayProps)
|
|
151
|
+
if (props.policyEngine && props.policyEngineMode) {
|
|
152
|
+
this.cfnGateway.addPropertyOverride('PolicyEngineConfiguration', {
|
|
153
|
+
Arn: props.policyEngine.policyEngineArn,
|
|
154
|
+
Mode: props.policyEngineMode,
|
|
155
|
+
});
|
|
156
|
+
// Ensure the policy engine is created before the gateway, since addPropertyOverride
|
|
157
|
+
// bypasses CDK's automatic dependency tracking for typed properties.
|
|
158
|
+
this.node.addDependency(props.policyEngine);
|
|
159
|
+
}
|
|
160
|
+
// Process gateway targets
|
|
161
|
+
for (const target of gateway.targets) {
|
|
162
|
+
this.createGatewayTarget(target, projectName, configRoot);
|
|
163
|
+
}
|
|
164
|
+
// Add IAM permissions based on auth types used
|
|
165
|
+
const oauthTargets = gateway.targets.filter(t => t.outboundAuth?.type === 'OAUTH' && t.outboundAuth.credentialName);
|
|
166
|
+
const apiKeyTargets = gateway.targets.filter(t => t.outboundAuth?.type === 'API_KEY' && t.outboundAuth.credentialName);
|
|
167
|
+
if (oauthTargets.length > 0) {
|
|
168
|
+
// OAuth requires permissions on workload identity, token vault, and credential provider resources
|
|
169
|
+
const stack = cdk.Stack.of(this);
|
|
170
|
+
const partition = stack.partition;
|
|
171
|
+
const providerArns = oauthTargets
|
|
172
|
+
.map(t => this.credentials?.[t.outboundAuth.credentialName]?.credentialProviderArn)
|
|
173
|
+
.filter((arn) => !!arn);
|
|
174
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
175
|
+
// On-behalf-of (TOKEN_EXCHANGE) OAuth targets exchange the caller's identity for a
|
|
176
|
+
// downstream token, which requires the ...ForJWT / ...ForUserId workload-token variants
|
|
177
|
+
// in addition to the base GetWorkloadAccessToken. Granting all three matches the harness
|
|
178
|
+
// and payment-manager roles (AgentCoreHarnessRole, AgentCorePaymentManager); omitting the
|
|
179
|
+
// ForJWT variant makes gateway-initiated OBO fail with AccessDenied inside AgentCore Identity.
|
|
180
|
+
actions: [
|
|
181
|
+
'bedrock-agentcore:GetResourceOauth2Token',
|
|
182
|
+
'bedrock-agentcore:GetWorkloadAccessToken',
|
|
183
|
+
'bedrock-agentcore:GetWorkloadAccessTokenForJWT',
|
|
184
|
+
'bedrock-agentcore:GetWorkloadAccessTokenForUserId',
|
|
185
|
+
],
|
|
186
|
+
resources: [
|
|
187
|
+
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:workload-identity-directory/default`,
|
|
188
|
+
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:workload-identity-directory/default/workload-identity/${this.cfnGateway.attrGatewayIdentifier}`,
|
|
189
|
+
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:token-vault/default`,
|
|
190
|
+
...providerArns,
|
|
191
|
+
],
|
|
192
|
+
}));
|
|
193
|
+
// Grant access to OAuth client secrets in Secrets Manager
|
|
194
|
+
const oauthSecretArns = oauthTargets
|
|
195
|
+
.map(t => this.credentials?.[t.outboundAuth.credentialName]?.clientSecretArn)
|
|
196
|
+
.filter((arn) => !!arn);
|
|
197
|
+
if (oauthSecretArns.length > 0) {
|
|
198
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
199
|
+
actions: ['secretsmanager:GetSecretValue'],
|
|
200
|
+
resources: oauthSecretArns,
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (apiKeyTargets.length > 0) {
|
|
205
|
+
const stack = cdk.Stack.of(this);
|
|
206
|
+
const partition = stack.partition;
|
|
207
|
+
// Grant permissions to retrieve API key credentials from AgentCore Identity
|
|
208
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
209
|
+
actions: [
|
|
210
|
+
'bedrock-agentcore:GetApiKeyCredential',
|
|
211
|
+
'bedrock-agentcore:GetResourceApiKey',
|
|
212
|
+
'bedrock-agentcore:GetWorkloadAccessToken',
|
|
213
|
+
],
|
|
214
|
+
resources: [
|
|
215
|
+
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:workload-identity-directory/*`,
|
|
216
|
+
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:token-vault/*`,
|
|
217
|
+
`arn:${partition}:bedrock-agentcore:${stack.region}:${stack.account}:apikeycredentialprovider/*`,
|
|
218
|
+
],
|
|
219
|
+
}));
|
|
220
|
+
// Grant Secrets Manager access for the underlying API key secrets
|
|
221
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
222
|
+
actions: ['secretsmanager:GetSecretValue'],
|
|
223
|
+
resources: [
|
|
224
|
+
`arn:${partition}:secretsmanager:${stack.region}:${stack.account}:secret:bedrock-agentcore-identity!*`,
|
|
225
|
+
],
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Adds a policy statement to the gateway's IAM role.
|
|
231
|
+
* Silently no-ops when using an imported role (mutable: false).
|
|
232
|
+
*/
|
|
233
|
+
addToPolicy(statement) {
|
|
234
|
+
if (this.role instanceof aws_cdk_lib_1.aws_iam.Role) {
|
|
235
|
+
this.role.addToPolicy(statement);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Builds the protocol configuration for a gateway.
|
|
240
|
+
* When semantic search is disabled, no protocol configuration is set.
|
|
241
|
+
* Otherwise, configures MCP with SEMANTIC search type.
|
|
242
|
+
*/
|
|
243
|
+
buildProtocolConfiguration(gateway) {
|
|
244
|
+
// 'SEMANTIC' is the only value CloudFormation accepts for Mcp.SearchType.
|
|
245
|
+
// To disable semantic search we must omit ProtocolConfiguration entirely —
|
|
246
|
+
// emitting 'NONE' produces a template that CloudFormation rejects.
|
|
247
|
+
if (gateway.enableSemanticSearch === false) {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
mcp: { searchType: 'SEMANTIC' },
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Builds credential provider configuration for a gateway target based on outbound auth.
|
|
256
|
+
*/
|
|
257
|
+
buildCredentialConfig(target) {
|
|
258
|
+
if (!target.outboundAuth || target.outboundAuth.type === 'NONE') {
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
const { type, credentialName, scopes } = target.outboundAuth;
|
|
262
|
+
// GATEWAY_IAM_ROLE and JWT_PASSTHROUGH don't use credential providers — handled by caller
|
|
263
|
+
if (type === 'GATEWAY_IAM_ROLE' || type === 'JWT_PASSTHROUGH') {
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
const credential = this.credentials?.[credentialName];
|
|
267
|
+
if (!credential) {
|
|
268
|
+
throw new Error(`Credential "${credentialName}" not found in deployed state`);
|
|
269
|
+
}
|
|
270
|
+
if (type === 'OAUTH') {
|
|
271
|
+
return [
|
|
272
|
+
{
|
|
273
|
+
credentialProviderType: 'OAUTH',
|
|
274
|
+
credentialProvider: {
|
|
275
|
+
oauthCredentialProvider: {
|
|
276
|
+
providerArn: credential.credentialProviderArn,
|
|
277
|
+
scopes: scopes ?? [],
|
|
278
|
+
grantType: 'CLIENT_CREDENTIALS',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
];
|
|
283
|
+
}
|
|
284
|
+
if (type === 'API_KEY') {
|
|
285
|
+
return [
|
|
286
|
+
{
|
|
287
|
+
credentialProviderType: 'API_KEY',
|
|
288
|
+
credentialProvider: {
|
|
289
|
+
apiKeyCredentialProvider: {
|
|
290
|
+
providerArn: credential.credentialProviderArn,
|
|
291
|
+
credentialLocation: 'HEADER',
|
|
292
|
+
credentialParameterName: 'x-api-key',
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
throw new Error(`Unsupported outbound auth type: ${String(type)}`);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Creates a Gateway Target with its associated compute.
|
|
302
|
+
*/
|
|
303
|
+
createGatewayTarget(target, projectName, configRoot) {
|
|
304
|
+
const targetName = target.name;
|
|
305
|
+
// Handle API Gateway targets (no compute required)
|
|
306
|
+
if (target.targetType === 'apiGateway' && target.apiGateway) {
|
|
307
|
+
const { restApiId, stage, apiGatewayToolConfiguration } = target.apiGateway;
|
|
308
|
+
const credentialProviderConfigurations = this.buildCredentialConfig(target);
|
|
309
|
+
// Grant execute-api:Invoke only when the gateway uses SigV4 (IAM/NONE auth).
|
|
310
|
+
// API_KEY auth sends the key in a header and doesn't need IAM-level invoke permission.
|
|
311
|
+
// When adding new auth types, consider whether the gateway SigV4-signs the request —
|
|
312
|
+
// if it does, execute-api:Invoke is required; if it uses a different auth mechanism, it's not.
|
|
313
|
+
if (!credentialProviderConfigurations) {
|
|
314
|
+
const stack = cdk.Stack.of(this);
|
|
315
|
+
const apiGatewayArn = `arn:${stack.partition}:execute-api:${stack.region}:${stack.account}:${restApiId}/${stage}/*`;
|
|
316
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
317
|
+
actions: ['execute-api:Invoke'],
|
|
318
|
+
resources: [apiGatewayArn],
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
const cfnTarget = new aws_cdk_lib_1.aws_bedrockagentcore.CfnGatewayTarget(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
322
|
+
gatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
323
|
+
name: targetName,
|
|
324
|
+
description: `API Gateway target: ${targetName}`,
|
|
325
|
+
targetConfiguration: {
|
|
326
|
+
mcp: {
|
|
327
|
+
apiGateway: {
|
|
328
|
+
restApiId,
|
|
329
|
+
stage,
|
|
330
|
+
apiGatewayToolConfiguration: {
|
|
331
|
+
toolFilters: apiGatewayToolConfiguration.toolFilters.map(f => ({
|
|
332
|
+
filterPath: f.filterPath,
|
|
333
|
+
methods: f.methods,
|
|
334
|
+
})),
|
|
335
|
+
...(apiGatewayToolConfiguration.toolOverrides && {
|
|
336
|
+
toolOverrides: apiGatewayToolConfiguration.toolOverrides.map(o => ({
|
|
337
|
+
name: o.name,
|
|
338
|
+
path: o.path,
|
|
339
|
+
method: o.method,
|
|
340
|
+
...(o.description && { description: o.description }),
|
|
341
|
+
})),
|
|
342
|
+
}),
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
credentialProviderConfigurations: credentialProviderConfigurations ??
|
|
348
|
+
(schema_1.TARGET_TYPE_AUTH_CONFIG.apiGateway.iamRoleFallback
|
|
349
|
+
? [{ credentialProviderType: 'GATEWAY_IAM_ROLE' }]
|
|
350
|
+
: undefined),
|
|
351
|
+
});
|
|
352
|
+
// The gateway service validates the role's permissions synchronously at
|
|
353
|
+
// CreateGatewayTarget time, so the target must be created after the role's
|
|
354
|
+
// DefaultPolicy. Depending on the role transitively includes its DefaultPolicy.
|
|
355
|
+
cfnTarget.node.addDependency(this.role);
|
|
356
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
// Handle Lambda Function ARN targets (no compute required)
|
|
360
|
+
if (target.targetType === 'lambdaFunctionArn' && target.lambdaFunctionArn) {
|
|
361
|
+
const { lambdaArn, toolSchemaFile } = target.lambdaFunctionArn;
|
|
362
|
+
// Grant the gateway role permission to invoke the Lambda function
|
|
363
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
364
|
+
actions: ['lambda:InvokeFunction'],
|
|
365
|
+
resources: [lambdaArn, `${lambdaArn}:*`],
|
|
366
|
+
}));
|
|
367
|
+
// Accept either a local file path (uploaded via CDK Assets) or a pre-existing
|
|
368
|
+
// s3:// URI (used as-is, typical after `agentcore import gateway`).
|
|
369
|
+
let toolSchemaS3Uri;
|
|
370
|
+
if (toolSchemaFile.startsWith('s3://')) {
|
|
371
|
+
toolSchemaS3Uri = toolSchemaFile;
|
|
372
|
+
const match = /^s3:\/\/([^/]+)\/(.+)$/.exec(toolSchemaFile);
|
|
373
|
+
if (match) {
|
|
374
|
+
const [, bucket, key] = match;
|
|
375
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
376
|
+
actions: ['s3:GetObject'],
|
|
377
|
+
resources: [`arn:${cdk.Stack.of(this).partition}:s3:::${bucket}/${key}`],
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
const resolvedSchemaPath = (0, lib_1.resolveCodeLocation)(toolSchemaFile, configRoot);
|
|
383
|
+
const schemaAsset = new aws_s3_assets_1.Asset(this, (0, logical_ids_1.toPascalId)('Schema', targetName), {
|
|
384
|
+
path: resolvedSchemaPath,
|
|
385
|
+
});
|
|
386
|
+
schemaAsset.grantRead(this.role);
|
|
387
|
+
toolSchemaS3Uri = `s3://${schemaAsset.s3BucketName}/${schemaAsset.s3ObjectKey}`;
|
|
388
|
+
}
|
|
389
|
+
const credentialProviderConfigurations = this.buildCredentialConfig(target) ?? [
|
|
390
|
+
{ credentialProviderType: 'GATEWAY_IAM_ROLE' },
|
|
391
|
+
];
|
|
392
|
+
const cfnTarget = new aws_cdk_lib_1.aws_bedrockagentcore.CfnGatewayTarget(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
393
|
+
gatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
394
|
+
name: targetName,
|
|
395
|
+
description: `Lambda function target: ${targetName}`,
|
|
396
|
+
targetConfiguration: {
|
|
397
|
+
mcp: {
|
|
398
|
+
lambda: {
|
|
399
|
+
lambdaArn,
|
|
400
|
+
toolSchema: {
|
|
401
|
+
s3: {
|
|
402
|
+
uri: toolSchemaS3Uri,
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
credentialProviderConfigurations,
|
|
409
|
+
});
|
|
410
|
+
// The gateway service validates lambda:InvokeFunction synchronously at
|
|
411
|
+
// CreateGatewayTarget time. That grant lives on the role's DefaultPolicy
|
|
412
|
+
// (a separate AWS::IAM::Policy), so the target must be created after it —
|
|
413
|
+
// depending on the role transitively includes its DefaultPolicy. Without
|
|
414
|
+
// this, CloudFormation could create the target before the policy attached,
|
|
415
|
+
// yielding a 400 "role lacks permission to invoke Lambda" and a rollback
|
|
416
|
+
// the CDK toolkit then surfaced as an opaque "NoStack" error.
|
|
417
|
+
cfnTarget.node.addDependency(this.role);
|
|
418
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
// Handle connector-typed targets (managed-service backed: KB retrieve + agentic-retrieve)
|
|
422
|
+
if (target.targetType === 'connector' && target.connectorId === 'bedrock-knowledge-bases') {
|
|
423
|
+
const defaults = connector_defaults_1.CONNECTOR_DEFAULTS[target.connectorId];
|
|
424
|
+
const stack = cdk.Stack.of(this);
|
|
425
|
+
// Real KB IDs match ^[A-Z0-9]{10}$; KB names start with a letter and may
|
|
426
|
+
// include dashes/underscores. The two formats can never collide.
|
|
427
|
+
const REAL_KB_ID_PATTERN = /^[A-Z0-9]{10}$/;
|
|
428
|
+
const resolveKbReference = (value) => {
|
|
429
|
+
if (REAL_KB_ID_PATTERN.test(value)) {
|
|
430
|
+
return {
|
|
431
|
+
resolvedId: value,
|
|
432
|
+
arn: `arn:${stack.partition}:bedrock:${stack.region}:${stack.account}:knowledge-base/${value}`,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
const kb = this.knowledgeBases?.get(value);
|
|
436
|
+
if (!kb) {
|
|
437
|
+
throw new Error(`Connector target "${targetName}" references knowledge base "${value}" but ` +
|
|
438
|
+
`no knowledgeBases[] entry with that name exists in the project. ` +
|
|
439
|
+
`To wire an external KB this project does not own, use its 10-character KB ID.`);
|
|
440
|
+
}
|
|
441
|
+
return { resolvedId: kb.knowledgeBaseId, kbConstruct: kb, arn: kb.knowledgeBaseArn };
|
|
442
|
+
};
|
|
443
|
+
const grantKbPermissions = (kbArn) => {
|
|
444
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
445
|
+
actions: ['bedrock:GetKnowledgeBase', 'bedrock:Retrieve'],
|
|
446
|
+
resources: [kbArn],
|
|
447
|
+
}));
|
|
448
|
+
};
|
|
449
|
+
// Resolve KB references within each configuration entry's parameterValues.
|
|
450
|
+
// The configurations array may contain Retrieve and/or AgenticRetrieveStream entries.
|
|
451
|
+
const configurations = target.configurations ?? [];
|
|
452
|
+
const kbDependencies = [];
|
|
453
|
+
// Build resolved CFN Configurations array
|
|
454
|
+
const cfnConfigurations = [];
|
|
455
|
+
for (const config of configurations) {
|
|
456
|
+
const pv = config.parameterValues;
|
|
457
|
+
if (config.name === 'Retrieve' && pv?.knowledgeBaseId) {
|
|
458
|
+
const { resolvedId, kbConstruct, arn } = resolveKbReference(pv.knowledgeBaseId);
|
|
459
|
+
grantKbPermissions(arn);
|
|
460
|
+
if (kbConstruct)
|
|
461
|
+
kbDependencies.push(kbConstruct);
|
|
462
|
+
cfnConfigurations.push({
|
|
463
|
+
Name: config.name,
|
|
464
|
+
...(config.description && { Description: config.description }),
|
|
465
|
+
ParameterValues: { ...pv, knowledgeBaseId: resolvedId },
|
|
466
|
+
...(config.parameterOverrides && {
|
|
467
|
+
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
468
|
+
Path: o.path,
|
|
469
|
+
...(o.description && { Description: o.description }),
|
|
470
|
+
...(o.visible !== undefined && { Visible: o.visible }),
|
|
471
|
+
})),
|
|
472
|
+
}),
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
else if (config.name === 'AgenticRetrieveStream' && Array.isArray(pv?.retrievers)) {
|
|
476
|
+
const retrievers = pv.retrievers;
|
|
477
|
+
const kbIds = retrievers.map(r => r.configuration.knowledgeBase.knowledgeBaseId);
|
|
478
|
+
const resolved = kbIds.map(value => resolveKbReference(value));
|
|
479
|
+
for (const r of resolved) {
|
|
480
|
+
grantKbPermissions(r.arn);
|
|
481
|
+
if (r.kbConstruct)
|
|
482
|
+
kbDependencies.push(r.kbConstruct);
|
|
483
|
+
}
|
|
484
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
485
|
+
actions: ['bedrock:AgenticRetrieveStream'],
|
|
486
|
+
resources: ['*'],
|
|
487
|
+
}));
|
|
488
|
+
const resolvedRetrievers = resolved.map((r, index) => {
|
|
489
|
+
const retriever = retrievers[index];
|
|
490
|
+
return {
|
|
491
|
+
...retriever,
|
|
492
|
+
configuration: {
|
|
493
|
+
...retriever.configuration,
|
|
494
|
+
knowledgeBase: {
|
|
495
|
+
...retriever.configuration.knowledgeBase,
|
|
496
|
+
knowledgeBaseId: r.resolvedId,
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
};
|
|
500
|
+
});
|
|
501
|
+
cfnConfigurations.push({
|
|
502
|
+
Name: config.name,
|
|
503
|
+
...(config.description && { Description: config.description }),
|
|
504
|
+
ParameterValues: { ...pv, retrievers: resolvedRetrievers },
|
|
505
|
+
...(config.parameterOverrides && {
|
|
506
|
+
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
507
|
+
Path: o.path,
|
|
508
|
+
...(o.description && { Description: o.description }),
|
|
509
|
+
...(o.visible !== undefined && { Visible: o.visible }),
|
|
510
|
+
})),
|
|
511
|
+
}),
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
// Pass through any other configuration entry as-is
|
|
516
|
+
cfnConfigurations.push({
|
|
517
|
+
Name: config.name,
|
|
518
|
+
...(config.description && { Description: config.description }),
|
|
519
|
+
...(pv && { ParameterValues: pv }),
|
|
520
|
+
...(config.parameterOverrides && {
|
|
521
|
+
ParameterOverrides: config.parameterOverrides.map(o => ({
|
|
522
|
+
Path: o.path,
|
|
523
|
+
...(o.description && { Description: o.description }),
|
|
524
|
+
...(o.visible !== undefined && { Visible: o.visible }),
|
|
525
|
+
})),
|
|
526
|
+
}),
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
// Derive the Enabled list from the configuration names
|
|
531
|
+
const enabled = cfnConfigurations.map(c => c.Name);
|
|
532
|
+
// CfnResource escape hatch: the typed L1 (CfnGatewayTarget) doesn't
|
|
533
|
+
// model the Connector branch under TargetConfiguration.Mcp yet.
|
|
534
|
+
const rawTarget = new cdk.CfnResource(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
535
|
+
type: 'AWS::BedrockAgentCore::GatewayTarget',
|
|
536
|
+
properties: {
|
|
537
|
+
GatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
538
|
+
Name: targetName,
|
|
539
|
+
Description: `${defaults.label} target: ${targetName}`,
|
|
540
|
+
CredentialProviderConfigurations: [{ CredentialProviderType: 'GATEWAY_IAM_ROLE' }],
|
|
541
|
+
TargetConfiguration: {
|
|
542
|
+
Mcp: {
|
|
543
|
+
Connector: {
|
|
544
|
+
Source: { ConnectorId: target.connectorId },
|
|
545
|
+
Enabled: enabled,
|
|
546
|
+
Configurations: cfnConfigurations,
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
});
|
|
552
|
+
const cfnTarget = Object.assign(rawTarget, {
|
|
553
|
+
attrTargetId: rawTarget.getAtt('TargetId').toString(),
|
|
554
|
+
});
|
|
555
|
+
cfnTarget.node.addDependency(this.cfnGateway);
|
|
556
|
+
const defaultPolicy = this.role.node.tryFindChild('DefaultPolicy');
|
|
557
|
+
if (defaultPolicy)
|
|
558
|
+
cfnTarget.node.addDependency(defaultPolicy);
|
|
559
|
+
for (const kb of kbDependencies) {
|
|
560
|
+
cfnTarget.node.addDependency(kb);
|
|
561
|
+
}
|
|
562
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
// Amazon Web Search target. ConnectorId='web-search', optional domain
|
|
566
|
+
// exclusion list. Gateway role needs InvokeWebSearch on the aws-owned tool ARN.
|
|
567
|
+
if (target.targetType === 'connector' && target.connectorId === 'web-search') {
|
|
568
|
+
const stack = cdk.Stack.of(this);
|
|
569
|
+
// The aws-owned web-search tool ARN is published in commercial regions
|
|
570
|
+
// only today. `stack.partition` will template aws-cn / aws-us-gov
|
|
571
|
+
// correctly, but the resource itself doesn't exist there — first
|
|
572
|
+
// tools/call would fail at runtime. Warn at synth so users know.
|
|
573
|
+
if (!cdk.Token.isUnresolved(stack.partition) && stack.partition !== 'aws') {
|
|
574
|
+
cdk.Annotations.of(this).addWarning(`web-search connector target "${targetName}" is being synthesized in partition "${stack.partition}", but ` +
|
|
575
|
+
`the underlying \`aws:tool/web-search.v1\` resource is currently only published in the commercial ` +
|
|
576
|
+
`(aws) partition. Tool invocations will fail at runtime in this partition.`);
|
|
577
|
+
}
|
|
578
|
+
const parameterValues = {};
|
|
579
|
+
const firstConfig = target.configurations?.[0];
|
|
580
|
+
const domainFilter = firstConfig?.parameterValues?.domainFilter;
|
|
581
|
+
if (domainFilter?.exclude && domainFilter.exclude.length > 0) {
|
|
582
|
+
parameterValues.domainFilter = { exclude: domainFilter.exclude };
|
|
583
|
+
}
|
|
584
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
585
|
+
actions: ['bedrock-agentcore:InvokeWebSearch'],
|
|
586
|
+
resources: [`arn:${stack.partition}:bedrock-agentcore:${stack.region}:aws:tool/web-search.v1`],
|
|
587
|
+
}));
|
|
588
|
+
// CfnResource escape hatch: typed L1 doesn't model the Connector branch
|
|
589
|
+
// under TargetConfiguration.Mcp yet.
|
|
590
|
+
const rawTarget = new cdk.CfnResource(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
591
|
+
type: 'AWS::BedrockAgentCore::GatewayTarget',
|
|
592
|
+
properties: {
|
|
593
|
+
GatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
594
|
+
Name: targetName,
|
|
595
|
+
Description: `Web Search target: ${targetName}`,
|
|
596
|
+
CredentialProviderConfigurations: [{ CredentialProviderType: 'GATEWAY_IAM_ROLE' }],
|
|
597
|
+
TargetConfiguration: {
|
|
598
|
+
Mcp: {
|
|
599
|
+
Connector: {
|
|
600
|
+
Source: { ConnectorId: 'web-search' },
|
|
601
|
+
Enabled: ['WebSearch'],
|
|
602
|
+
Configurations: [
|
|
603
|
+
{
|
|
604
|
+
Name: 'WebSearch',
|
|
605
|
+
...(target.configurations?.[0]?.description && {
|
|
606
|
+
Description: target.configurations[0].description,
|
|
607
|
+
}),
|
|
608
|
+
ParameterValues: parameterValues,
|
|
609
|
+
},
|
|
610
|
+
],
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
});
|
|
616
|
+
// The raw CfnResource has no typed `attrTargetId`; attach one so the
|
|
617
|
+
// target can be stored in `gatewayTargets` and surfaced as a CfnOutput
|
|
618
|
+
// by AgentCoreMcp (same shim as the connector branch).
|
|
619
|
+
const cfnTarget = Object.assign(rawTarget, {
|
|
620
|
+
attrTargetId: rawTarget.getAtt('TargetId').toString(),
|
|
621
|
+
});
|
|
622
|
+
cfnTarget.node.addDependency(this.cfnGateway);
|
|
623
|
+
if (this.role instanceof aws_cdk_lib_1.aws_iam.Role) {
|
|
624
|
+
cfnTarget.node.addDependency(this.role);
|
|
625
|
+
}
|
|
626
|
+
const wsDefaultPolicy = this.role.node.tryFindChild('DefaultPolicy');
|
|
627
|
+
if (wsDefaultPolicy)
|
|
628
|
+
cfnTarget.node.addDependency(wsDefaultPolicy);
|
|
629
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
// Handle external MCP server endpoints (no compute required)
|
|
633
|
+
if (target.targetType === 'mcpServer' && target.endpoint && !target.compute) {
|
|
634
|
+
const credentialProviderConfigurations = this.buildCredentialConfig(target);
|
|
635
|
+
const cfnTarget = new aws_cdk_lib_1.aws_bedrockagentcore.CfnGatewayTarget(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
636
|
+
gatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
637
|
+
name: targetName,
|
|
638
|
+
description: `External MCP server: ${targetName}`,
|
|
639
|
+
targetConfiguration: {
|
|
640
|
+
mcp: {
|
|
641
|
+
mcpServer: { endpoint: target.endpoint },
|
|
642
|
+
},
|
|
643
|
+
},
|
|
644
|
+
credentialProviderConfigurations,
|
|
645
|
+
});
|
|
646
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
// Handle Passthrough targets
|
|
650
|
+
if (target.targetType === 'passthrough') {
|
|
651
|
+
if (!target.passthrough) {
|
|
652
|
+
throw new Error(`Gateway target "${targetName}" of type passthrough requires a passthrough configuration.`);
|
|
653
|
+
}
|
|
654
|
+
// Build credential config: use outbound auth if specified, otherwise no fallback
|
|
655
|
+
const passthroughCredConfig = this.buildCredentialConfig(target);
|
|
656
|
+
let passthroughCredentialProviderConfigurations;
|
|
657
|
+
if (passthroughCredConfig) {
|
|
658
|
+
passthroughCredentialProviderConfigurations = passthroughCredConfig.map(c => {
|
|
659
|
+
const entry = {
|
|
660
|
+
CredentialProviderType: String(c.credentialProviderType).toUpperCase(),
|
|
661
|
+
};
|
|
662
|
+
if (c.credentialProvider) {
|
|
663
|
+
const provider = c.credentialProvider;
|
|
664
|
+
const cp = {};
|
|
665
|
+
if (provider.oauthCredentialProvider) {
|
|
666
|
+
const oauth = provider.oauthCredentialProvider;
|
|
667
|
+
cp.OauthCredentialProvider = {
|
|
668
|
+
ProviderArn: oauth.providerArn,
|
|
669
|
+
Scopes: oauth.scopes,
|
|
670
|
+
GrantType: oauth.grantType ?? 'CLIENT_CREDENTIALS',
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
if (provider.apiKeyCredentialProvider) {
|
|
674
|
+
const apiKey = provider.apiKeyCredentialProvider;
|
|
675
|
+
cp.ApiKeyCredentialProvider = {
|
|
676
|
+
ProviderArn: apiKey.providerArn,
|
|
677
|
+
CredentialLocation: apiKey.credentialLocation,
|
|
678
|
+
CredentialParameterName: apiKey.credentialParameterName,
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
entry.CredentialProvider = cp;
|
|
682
|
+
}
|
|
683
|
+
return entry;
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
else if (target.outboundAuth?.type === 'GATEWAY_IAM_ROLE') {
|
|
687
|
+
passthroughCredentialProviderConfigurations = [
|
|
688
|
+
{
|
|
689
|
+
CredentialProviderType: 'GATEWAY_IAM_ROLE',
|
|
690
|
+
CredentialProvider: {
|
|
691
|
+
IamCredentialProvider: {
|
|
692
|
+
Service: target.outboundAuth.service,
|
|
693
|
+
...(target.outboundAuth.region && { Region: target.outboundAuth.region }),
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
];
|
|
698
|
+
}
|
|
699
|
+
else if (target.outboundAuth?.type === 'JWT_PASSTHROUGH') {
|
|
700
|
+
passthroughCredentialProviderConfigurations = [
|
|
701
|
+
{
|
|
702
|
+
CredentialProviderType: 'JWT_PASSTHROUGH',
|
|
703
|
+
},
|
|
704
|
+
];
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
// Fallback for passthrough targets without explicit auth
|
|
708
|
+
passthroughCredentialProviderConfigurations = [{ CredentialProviderType: 'GATEWAY_IAM_ROLE' }];
|
|
709
|
+
}
|
|
710
|
+
// Build passthrough target configuration
|
|
711
|
+
const passthroughConfig = {
|
|
712
|
+
Endpoint: target.passthrough.endpoint,
|
|
713
|
+
ProtocolType: target.passthrough.protocolType ?? 'CUSTOM',
|
|
714
|
+
};
|
|
715
|
+
if (target.passthrough.stickinessConfiguration) {
|
|
716
|
+
const stickiness = {
|
|
717
|
+
Identifier: target.passthrough.stickinessConfiguration.identifier,
|
|
718
|
+
};
|
|
719
|
+
if (target.passthrough.stickinessConfiguration.timeout) {
|
|
720
|
+
stickiness.Timeout = target.passthrough.stickinessConfiguration.timeout;
|
|
721
|
+
}
|
|
722
|
+
passthroughConfig.StickinessConfiguration = stickiness;
|
|
723
|
+
}
|
|
724
|
+
// Use CfnResource directly to avoid CDK L1 type system issues
|
|
725
|
+
const rawTarget = new cdk.CfnResource(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
726
|
+
type: 'AWS::BedrockAgentCore::GatewayTarget',
|
|
727
|
+
properties: {
|
|
728
|
+
GatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
729
|
+
Name: targetName,
|
|
730
|
+
Description: `Passthrough target: ${targetName}`,
|
|
731
|
+
TargetConfiguration: {
|
|
732
|
+
Http: {
|
|
733
|
+
Passthrough: passthroughConfig,
|
|
734
|
+
},
|
|
735
|
+
},
|
|
736
|
+
CredentialProviderConfigurations: passthroughCredentialProviderConfigurations,
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
// Create a compatible reference for the gatewayTargets map
|
|
740
|
+
const cfnTarget = Object.assign(rawTarget, {
|
|
741
|
+
attrTargetId: rawTarget.getAtt('TargetId').toString(),
|
|
742
|
+
});
|
|
743
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
// Handle HTTP Runtime targets
|
|
747
|
+
if (target.targetType === 'httpRuntime') {
|
|
748
|
+
if (!target.httpRuntime) {
|
|
749
|
+
throw new Error(`Gateway target "${targetName}" of type httpRuntime requires an httpRuntime configuration.`);
|
|
750
|
+
}
|
|
751
|
+
if (!this.props.runtimeArns) {
|
|
752
|
+
throw new Error(`Gateway target "${targetName}": no runtimeArns map provided.`);
|
|
753
|
+
}
|
|
754
|
+
const runtimeArn = this.props.runtimeArns.get(target.httpRuntime.runtime);
|
|
755
|
+
if (!runtimeArn) {
|
|
756
|
+
throw new Error(`Gateway target "${targetName}": could not resolve runtime "${target.httpRuntime.runtime}" to an ARN.`);
|
|
757
|
+
}
|
|
758
|
+
// Build credential config: use outbound auth if specified, otherwise default to GATEWAY_IAM_ROLE
|
|
759
|
+
const httpRuntimeCredConfig = this.buildCredentialConfig(target);
|
|
760
|
+
let credentialProviderConfigurations;
|
|
761
|
+
if (httpRuntimeCredConfig) {
|
|
762
|
+
credentialProviderConfigurations = httpRuntimeCredConfig.map(c => {
|
|
763
|
+
const entry = {
|
|
764
|
+
CredentialProviderType: String(c.credentialProviderType).toUpperCase(),
|
|
765
|
+
};
|
|
766
|
+
if (c.credentialProvider) {
|
|
767
|
+
const provider = c.credentialProvider;
|
|
768
|
+
const cp = {};
|
|
769
|
+
if (provider.oauthCredentialProvider) {
|
|
770
|
+
const oauth = provider.oauthCredentialProvider;
|
|
771
|
+
cp.OauthCredentialProvider = {
|
|
772
|
+
ProviderArn: oauth.providerArn,
|
|
773
|
+
Scopes: oauth.scopes,
|
|
774
|
+
GrantType: oauth.grantType ?? 'CLIENT_CREDENTIALS',
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
if (provider.apiKeyCredentialProvider) {
|
|
778
|
+
const apiKey = provider.apiKeyCredentialProvider;
|
|
779
|
+
cp.ApiKeyCredentialProvider = {
|
|
780
|
+
ProviderArn: apiKey.providerArn,
|
|
781
|
+
CredentialLocation: apiKey.credentialLocation,
|
|
782
|
+
CredentialParameterName: apiKey.credentialParameterName,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
entry.CredentialProvider = cp;
|
|
786
|
+
}
|
|
787
|
+
return entry;
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
credentialProviderConfigurations = [{ CredentialProviderType: 'GATEWAY_IAM_ROLE' }];
|
|
792
|
+
}
|
|
793
|
+
// Use CfnResource directly to avoid CDK L1 type system merging typed union properties
|
|
794
|
+
const rawTarget = new cdk.CfnResource(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
795
|
+
type: 'AWS::BedrockAgentCore::GatewayTarget',
|
|
796
|
+
properties: {
|
|
797
|
+
GatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
798
|
+
Name: targetName,
|
|
799
|
+
Description: `HTTP runtime target: ${targetName}`,
|
|
800
|
+
TargetConfiguration: {
|
|
801
|
+
Http: {
|
|
802
|
+
AgentcoreRuntime: {
|
|
803
|
+
Arn: runtimeArn,
|
|
804
|
+
...(target.httpRuntime.runtimeEndpoint && {
|
|
805
|
+
Qualifier: target.httpRuntime.runtimeEndpoint,
|
|
806
|
+
}),
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
CredentialProviderConfigurations: credentialProviderConfigurations,
|
|
811
|
+
},
|
|
812
|
+
});
|
|
813
|
+
// Create a compatible reference for the gatewayTargets map (needs attrTargetId)
|
|
814
|
+
const cfnTarget = Object.assign(rawTarget, {
|
|
815
|
+
attrTargetId: rawTarget.getAtt('TargetId').toString(),
|
|
816
|
+
});
|
|
817
|
+
// Grant the gateway role permission to invoke the runtime.
|
|
818
|
+
// The gateway calls bedrock-agentcore:InvokeAgentRuntime — the only valid
|
|
819
|
+
// invoke action per the IAM service-authorization reference. The previous
|
|
820
|
+
// grant used InvokeRuntime, which is not a real action, so IAM ignored it
|
|
821
|
+
// and every invoke 403'd. User-context invocation is the same action plus
|
|
822
|
+
// the X-Amzn-Bedrock-AgentCore-Runtime-User-Id header, not a separate action.
|
|
823
|
+
this.addToPolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
824
|
+
actions: ['bedrock-agentcore:InvokeAgentRuntime'],
|
|
825
|
+
resources: [runtimeArn, `${runtimeArn}/runtime-endpoint/*`],
|
|
826
|
+
}));
|
|
827
|
+
// The gateway service validates the role's InvokeAgentRuntime permission
|
|
828
|
+
// synchronously at CreateGatewayTarget time. That grant lives on the role's
|
|
829
|
+
// DefaultPolicy, so the target must be created after it — depending on the
|
|
830
|
+
// role transitively includes its DefaultPolicy.
|
|
831
|
+
cfnTarget.node.addDependency(this.role);
|
|
832
|
+
// Store the target reference for output generation
|
|
833
|
+
this.gatewayTargets.set(targetName, cfnTarget);
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
// Handle OpenAPI / Smithy schema-based targets
|
|
837
|
+
if (target.targetType === 'openApiSchema' || target.targetType === 'smithyModel') {
|
|
838
|
+
if (!target.schemaSource) {
|
|
839
|
+
throw new Error(`Gateway target "${targetName}" of type ${target.targetType} requires a schemaSource.`);
|
|
840
|
+
}
|
|
841
|
+
let schemaConfig;
|
|
842
|
+
if ('s3' in target.schemaSource && target.schemaSource.s3) {
|
|
843
|
+
// User-provided S3 URI — pass directly to CFN
|
|
844
|
+
schemaConfig = {
|
|
845
|
+
s3: {
|
|
846
|
+
uri: target.schemaSource.s3.uri,
|
|
847
|
+
bucketOwnerAccountId: target.schemaSource.s3.bucketOwnerAccountId,
|
|
848
|
+
},
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
else if ('inline' in target.schemaSource && target.schemaSource.inline) {
|
|
852
|
+
// Local file — upload via CDK Asset, reference as S3 URI
|
|
853
|
+
// Resolve relative to project root (parent of agentcore/)
|
|
854
|
+
const projectRoot = (0, path_1.dirname)(configRoot);
|
|
855
|
+
const schemaPath = (0, path_1.isAbsolute)(target.schemaSource.inline.path)
|
|
856
|
+
? target.schemaSource.inline.path
|
|
857
|
+
: (0, path_1.join)(projectRoot, target.schemaSource.inline.path);
|
|
858
|
+
const schemaAsset = new aws_s3_assets_1.Asset(this, (0, logical_ids_1.toPascalId)('SchemaAsset', targetName), {
|
|
859
|
+
path: schemaPath,
|
|
860
|
+
});
|
|
861
|
+
schemaAsset.grantRead(this.role);
|
|
862
|
+
schemaConfig = {
|
|
863
|
+
s3: { uri: `s3://${schemaAsset.s3BucketName}/${schemaAsset.s3ObjectKey}` },
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
throw new Error(`Invalid schemaSource for target "${targetName}".`);
|
|
868
|
+
}
|
|
869
|
+
const credentialProviderConfigurations = this.buildCredentialConfig(target);
|
|
870
|
+
const targetConfiguration = {
|
|
871
|
+
mcp: target.targetType === 'openApiSchema' ? { openApiSchema: schemaConfig } : { smithyModel: schemaConfig },
|
|
872
|
+
};
|
|
873
|
+
const authConfig = schema_1.TARGET_TYPE_AUTH_CONFIG[target.targetType];
|
|
874
|
+
if (authConfig.authRequired && !credentialProviderConfigurations) {
|
|
875
|
+
throw new Error(`Target "${targetName}" of type ${target.targetType} requires outbound auth ` +
|
|
876
|
+
`(${authConfig.validAuthTypes.join(' or ')}). ` +
|
|
877
|
+
`Register a credential with 'agentcore add identity' and reference it via outboundAuth.`);
|
|
878
|
+
}
|
|
879
|
+
const gatewayTarget = new aws_cdk_lib_1.aws_bedrockagentcore.CfnGatewayTarget(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
880
|
+
gatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
881
|
+
name: targetName,
|
|
882
|
+
description: `${target.targetType} target: ${targetName}`,
|
|
883
|
+
targetConfiguration,
|
|
884
|
+
credentialProviderConfigurations: credentialProviderConfigurations ??
|
|
885
|
+
(authConfig.iamRoleFallback ? [{ credentialProviderType: 'GATEWAY_IAM_ROLE' }] : undefined),
|
|
886
|
+
});
|
|
887
|
+
gatewayTarget.node.addDependency(this.role);
|
|
888
|
+
this.gatewayTargets.set(targetName, gatewayTarget);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (!target.compute) {
|
|
892
|
+
throw new Error(`Gateway target "${targetName}" must specify compute configuration. ` +
|
|
893
|
+
`Supported compute hosts: Lambda, AgentCoreRuntime`);
|
|
894
|
+
}
|
|
895
|
+
// Configure credential provider to use the gateway's IAM role
|
|
896
|
+
const credentialProviderConfigurations = this.buildCredentialConfig(target);
|
|
897
|
+
const computeHost = target.compute.host;
|
|
898
|
+
let targetConfiguration;
|
|
899
|
+
switch (computeHost) {
|
|
900
|
+
case 'Lambda': {
|
|
901
|
+
// Use toPascalId to convert dynamic target names to valid construct IDs
|
|
902
|
+
const lambdaCompute = new McpLambdaCompute_1.McpLambdaCompute(this, (0, logical_ids_1.toPascalId)('Lambda', targetName), {
|
|
903
|
+
toolName: targetName,
|
|
904
|
+
compute: target.compute,
|
|
905
|
+
projectName,
|
|
906
|
+
configRoot,
|
|
907
|
+
});
|
|
908
|
+
// Store reference and grant gateway invoke permission
|
|
909
|
+
this.lambdaFunctions.set(targetName, lambdaCompute.lambdaFunction);
|
|
910
|
+
lambdaCompute.lambdaFunction.grantInvoke(this.role);
|
|
911
|
+
// Build tool schema payload for all tools in this target
|
|
912
|
+
const toolSchemaPayloads = (target.toolDefinitions ?? []).map(toolDef => {
|
|
913
|
+
const payload = {
|
|
914
|
+
name: toolDef.name,
|
|
915
|
+
description: toolDef.description,
|
|
916
|
+
inputSchema: toolDef.inputSchema,
|
|
917
|
+
};
|
|
918
|
+
if (toolDef.outputSchema) {
|
|
919
|
+
payload.outputSchema = toolDef.outputSchema;
|
|
920
|
+
}
|
|
921
|
+
return payload;
|
|
922
|
+
});
|
|
923
|
+
targetConfiguration = {
|
|
924
|
+
mcp: {
|
|
925
|
+
lambda: {
|
|
926
|
+
lambdaArn: lambdaCompute.lambdaFunction.functionArn,
|
|
927
|
+
toolSchema: { inlinePayload: toolSchemaPayloads },
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
};
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
case 'AgentCoreRuntime': {
|
|
934
|
+
// Use toPascalId to convert dynamic target names to valid construct IDs
|
|
935
|
+
const runtimeCompute = new McpRuntimeCompute_1.McpRuntimeCompute(this, (0, logical_ids_1.toPascalId)('Runtime', targetName), {
|
|
936
|
+
toolName: targetName,
|
|
937
|
+
compute: target.compute,
|
|
938
|
+
projectName,
|
|
939
|
+
});
|
|
940
|
+
// Store reference and grant gateway invoke permission
|
|
941
|
+
this.runtimes.set(targetName, runtimeCompute.runtime);
|
|
942
|
+
runtimeCompute.grantInvoke(this.role);
|
|
943
|
+
targetConfiguration = {
|
|
944
|
+
mcp: {
|
|
945
|
+
mcpServer: { endpoint: runtimeCompute.endpointUrl },
|
|
946
|
+
},
|
|
947
|
+
};
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
default: {
|
|
951
|
+
const _exhaustive = computeHost;
|
|
952
|
+
throw new Error(`Unsupported compute host: ${String(_exhaustive)}`);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
// Concatenate tool descriptions for target description (max 200 chars)
|
|
956
|
+
const targetDescription = (target.toolDefinitions ?? [])
|
|
957
|
+
.map(t => t.description)
|
|
958
|
+
.join('; ')
|
|
959
|
+
.slice(0, 200);
|
|
960
|
+
const authConfig = schema_1.TARGET_TYPE_AUTH_CONFIG[target.targetType];
|
|
961
|
+
// Use toPascalId to convert dynamic target names to valid construct IDs
|
|
962
|
+
const gatewayTarget = new aws_cdk_lib_1.aws_bedrockagentcore.CfnGatewayTarget(this, (0, logical_ids_1.toPascalId)('Target', targetName), {
|
|
963
|
+
credentialProviderConfigurations: credentialProviderConfigurations ??
|
|
964
|
+
(authConfig.iamRoleFallback ? [{ credentialProviderType: 'GATEWAY_IAM_ROLE' }] : undefined),
|
|
965
|
+
name: targetName,
|
|
966
|
+
targetConfiguration,
|
|
967
|
+
description: targetDescription,
|
|
968
|
+
gatewayIdentifier: this.cfnGateway.attrGatewayIdentifier,
|
|
969
|
+
});
|
|
970
|
+
// Ensure the gateway target is created after the role has all permissions
|
|
971
|
+
gatewayTarget.node.addDependency(this.role);
|
|
972
|
+
this.gatewayTargets.set(targetName, gatewayTarget);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
exports.Gateway = Gateway;
|
|
976
|
+
//# sourceMappingURL=Gateway.js.map
|