@aws/nx-plugin 1.0.0-rc.17 → 1.0.0-rc.19
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/generators.json +9 -1
- package/package.json +1 -1
- package/src/agentcore-gateway/attach-upstream.d.ts +33 -0
- package/src/agentcore-gateway/attach-upstream.js +41 -0
- package/src/agentcore-gateway/attach-upstream.js.map +1 -0
- package/src/agentcore-gateway/files/project/serve-local.ts.template +3 -2
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +21 -0
- package/src/agentcore-gateway/gateway-connection/generator.js +102 -0
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/gateway-connection/schema.d.ts +12 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +26 -0
- package/src/agentcore-gateway/mcp-connection/generator.js +8 -24
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/connection/generator.js +66 -63
- package/src/connection/generator.js.map +1 -1
- package/src/license/generator.js +8 -19
- package/src/license/generator.js.map +1 -1
- package/src/license/known-exceptions.d.ts +0 -1
- package/src/license/known-exceptions.js +1 -8
- package/src/license/known-exceptions.js.map +1 -1
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +15 -6
- package/src/py/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +201 -0
- package/src/py/agent/a2a-connection/files/agent-connection/app/{__targetAgentSnakeCase___client.py.template → __targetAgentSnakeCase___client_strands.py.template} +7 -5
- package/src/py/agent/a2a-connection/generator.js +6 -5
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/files/http/main.py.template +2 -2
- package/src/py/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +197 -0
- package/src/py/agent/gateway-connection/files/agent-connection/app/{__gatewaySnakeCase___client.py.template → __gatewaySnakeCase___client_strands.py.template} +6 -6
- package/src/py/agent/gateway-connection/generator.js +5 -5
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/generator.js +3 -5
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +157 -79
- package/src/py/agent/mcp-connection/files/agent-connection/app/{__mcpServerSnakeCase___client.py.template → __mcpServerSnakeCase___client_strands.py.template} +7 -5
- package/src/py/agent/mcp-connection/generator.js +5 -5
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +37 -3
- package/src/py/fast-api/files/app/__name__/main.py.template +4 -1
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +13 -4
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/smithy/project/files/src/operations/echo.smithy.template +1 -0
- package/src/terraform/project/files/application/src/main.tf.template +6 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +35 -4
- package/src/trpc/backend/files/src/procedures/echo.ts.template +1 -1
- package/src/trpc/backend/files/src/schema/echo.ts.template +2 -2
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +14 -5
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +256 -0
- package/src/ts/agent/a2a-connection/files/agent-connection/app/{__targetAgentKebabCase__-client.ts.template → __targetAgentKebabCase__-client-strands.ts.template} +5 -5
- package/src/ts/agent/a2a-connection/generator.js +3 -3
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/files/http/router.ts.template +1 -1
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +220 -0
- package/src/ts/agent/gateway-connection/files/agent-connection/app/{__gatewayKebabCase__-client.ts.template → __gatewayKebabCase__-client-strands.ts.template} +5 -5
- package/src/ts/agent/gateway-connection/generator.js +3 -3
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.js +3 -0
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +183 -110
- package/src/ts/agent/mcp-connection/files/agent-connection/app/{__mcpServerKebabCase__-client.ts.template → __mcpServerKebabCase__-client-strands.ts.template} +5 -5
- package/src/ts/agent/mcp-connection/generator.js +3 -3
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +13 -4
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +64 -24
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +13 -4
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +9 -3
- package/src/utils/agent-connection/agent-connection.d.ts +50 -24
- package/src/utils/agent-connection/agent-connection.js +137 -45
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +93 -0
- package/src/utils/agent-connection/files/core-auth/agentcore-endpoints.ts.template +37 -0
- package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +54 -0
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +41 -0
- package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +70 -0
- package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +39 -0
- package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +61 -0
- package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +26 -0
- package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +27 -0
- package/src/utils/agent-connection/files/py-core-a2a/agentcore_a2a_client_config.py.template +43 -0
- package/src/utils/agent-connection/files/py-core-auth/agentcore_endpoints.py.template +47 -0
- package/src/utils/agent-connection/files/py-core-auth/auth/session.py.template +51 -0
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_transport.py.template +28 -0
- package/src/utils/agent-connection/files/py-core-mcp/agentcore_mcp_transport.py.template +34 -0
- package/src/utils/agent-connection/files/py-core-shared/agentcore_transport.py.template +40 -0
- package/src/utils/agent-connection/files/py-core-strands/a2a/agentcore_a2a_client_strands.py.template +66 -0
- package/src/utils/agent-connection/files/py-core-strands/gateway/agentcore_gateway_mcp_client_strands.py.template +22 -0
- package/src/utils/agent-connection/files/py-core-strands/mcp/agentcore_mcp_client_strands.py.template +30 -0
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +3 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +110 -28
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +95 -2
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +13 -4
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +9 -0
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +23 -1
- package/src/utils/files/terraform/src/core/runtime-config/appconfig-deployment/appconfig-deployment.tf.template +9 -3
- package/src/utils/files/terraform/src/core/runtime-config/read/read.tf.template +7 -2
- package/src/utils/identity-constructs/files/terraform/core/user-identity/add-callback-url/add-callback-url.tf.template +9 -3
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +22 -8
- package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +10 -4
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +13 -4
- package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client.ts.template +0 -123
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-client.ts.template +0 -78
- package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-client.ts.template +0 -128
- package/src/utils/agent-connection/files/py-core-a2a/agentcore_a2a_client.py.template +0 -120
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_client.py.template +0 -78
- package/src/utils/agent-connection/files/py-core-mcp/agentcore_mcp_client.py.template +0 -89
- /package/src/utils/agent-connection/files/{core-runtime-config/model-errors.ts.template → core-strands/base/model-errors-strands.ts.template} +0 -0
- /package/src/utils/agent-connection/files/{core-runtime-config/with-session-id.ts.template → core-strands/base/with-session-id-strands.ts.template} +0 -0
- /package/src/utils/agent-connection/files/{py-core-runtime-config/model_errors.py.template → py-core-strands/base/model_errors_strands.py.template} +0 -0
- /package/src/utils/agent-connection/files/{py-core-runtime-config/with_session_id.py.template → py-core-strands/base/with_session_id_strands.py.template} +0 -0
|
@@ -2,19 +2,21 @@ import os
|
|
|
2
2
|
|
|
3
3
|
from strands.tools.mcp.mcp_client import MCPClient
|
|
4
4
|
|
|
5
|
-
from <%- agentConnectionModuleName %>.core.
|
|
5
|
+
from <%- agentConnectionModuleName %>.core.agentcore_mcp_client_strands import (
|
|
6
|
+
AgentCoreMCPClientStrands,
|
|
7
|
+
)
|
|
6
8
|
from <%- agentConnectionModuleName %>.core.runtime_config import (
|
|
7
9
|
get_agentcore_runtime_config,
|
|
8
10
|
)
|
|
9
11
|
|
|
10
12
|
|
|
11
|
-
class <%- mcpServerClassName %>
|
|
12
|
-
"""
|
|
13
|
+
class <%- mcpServerClassName %>ClientStrands:
|
|
14
|
+
"""Strands client for the <%- mcpServerClassName %> MCP server."""
|
|
13
15
|
|
|
14
16
|
@staticmethod
|
|
15
17
|
def create() -> MCPClient:
|
|
16
18
|
if os.environ.get("SERVE_LOCAL") == "true":
|
|
17
|
-
return
|
|
19
|
+
return AgentCoreMCPClientStrands.without_auth(
|
|
18
20
|
"http://localhost:<%- mcpServerPort %>/mcp"
|
|
19
21
|
)
|
|
20
22
|
config = get_agentcore_runtime_config()
|
|
@@ -25,4 +27,4 @@ class <%- mcpServerClassName %>Client:
|
|
|
25
27
|
raise RuntimeError(
|
|
26
28
|
"No connected MCP server runtime named '<%- mcpServerClassName %>' found in runtime configuration."
|
|
27
29
|
)
|
|
28
|
-
return
|
|
30
|
+
return AgentCoreMCPClientStrands.with_iam_auth(agent_runtime_arn)
|
|
@@ -32,17 +32,17 @@ const pyAgentMcpConnectionGenerator = async (tree, options) => {
|
|
|
32
32
|
// 1. Ensure the shared Python agent-connection project exists + has the
|
|
33
33
|
// MCP core client and its shared SigV4 auth helper.
|
|
34
34
|
await (0, agent_connection_1.ensurePythonAgentConnectionProject)(tree);
|
|
35
|
-
(0, agent_connection_1.addPythonCoreClient)(tree, '
|
|
36
|
-
(0, agent_connection_1.addPythonCoreClient)(tree, 'mcp');
|
|
35
|
+
await (0, agent_connection_1.addPythonCoreClient)(tree, 'mcp');
|
|
37
36
|
const agentConnectionProjectDir = (0, agent_connection_1.getPythonAgentConnectionProjectDir)(tree);
|
|
38
37
|
const agentConnectionModuleName = (0, agent_connection_1.getPythonAgentConnectionModuleName)(tree);
|
|
39
38
|
const agentConnectionPackageName = (0, agent_connection_1.getPythonAgentConnectionPackageName)(tree);
|
|
40
39
|
// Python deps required by the MCP core client + shared auth helper.
|
|
40
|
+
// Layer 0/1 deps for the MCP transport + signed httpx auth. The framework's
|
|
41
|
+
// own dependency (strands-agents) is added by addPythonCoreClient.
|
|
41
42
|
(0, py_1.addDependenciesToPyProjectToml)(tree, agentConnectionProjectDir, [
|
|
42
43
|
'boto3',
|
|
43
44
|
'httpx',
|
|
44
45
|
'mcp',
|
|
45
|
-
'strands-agents',
|
|
46
46
|
]);
|
|
47
47
|
// 2. Generate the per-connection client into the shared agent-connection project
|
|
48
48
|
const appDir = (0, devkit_1.joinPathFragments)(agentConnectionProjectDir, agentConnectionModuleName, 'app');
|
|
@@ -59,12 +59,12 @@ const pyAgentMcpConnectionGenerator = async (tree, options) => {
|
|
|
59
59
|
}
|
|
60
60
|
// Add re-export to module __init__.py
|
|
61
61
|
const moduleInitPath = (0, devkit_1.joinPathFragments)(agentConnectionProjectDir, agentConnectionModuleName, '__init__.py');
|
|
62
|
-
await (0, agent_connection_1.addPythonReExport)(tree, moduleInitPath, `.app.${mcpServerSnakeCase}
|
|
62
|
+
await (0, agent_connection_1.addPythonReExport)(tree, moduleInitPath, `.app.${mcpServerSnakeCase}_client_strands`, `${mcpServerClassName}ClientStrands`);
|
|
63
63
|
// 3. Transform agent.py to add MCP client import and usage
|
|
64
64
|
const agentSourceDir = (0, devkit_1.joinPathFragments)(sourceProject.root, agentComponent.path ?? 'src');
|
|
65
65
|
const agentFilePath = (0, devkit_1.joinPathFragments)(agentSourceDir, 'agent.py');
|
|
66
66
|
if (tree.exists(agentFilePath)) {
|
|
67
|
-
const clientClassName = `${mcpServerClassName}
|
|
67
|
+
const clientClassName = `${mcpServerClassName}ClientStrands`;
|
|
68
68
|
const clientVarName = mcpServerSnakeCase;
|
|
69
69
|
await (0, ast_1.addPythonDestructuredImport)(tree, agentFilePath, [clientClassName], agentConnectionModuleName);
|
|
70
70
|
await (0, agent_connection_1.addPythonClientToAgent)(tree, agentFilePath, clientClassName, clientVarName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/nx-plugin/src/py/agent/mcp-connection/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAQoB;AACpB,uFAQ0D;AAC1D,4CAAiE;AACjE,kDAA6D;AAC7D,oDAAyE;AACzE,gDAAiD;AACjD,0CAK2B;AAC3B,0CAG2B;AAGd,QAAA,sCAAsC,GACjD,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,6BAA6B,GAAG,KAAK,EAChD,IAAU,EACV,OAA4C,EAChB,EAAE;IAC9B,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IAEF,MAAM,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAC/C,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC;IAE7C,IAAI,CAAC,cAAc,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;IACJ,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,0EAA0E,YAAY,CAAC,IAAI,WAAW,YAAY,CAAC,IAAI,mBAAmB,CAC3I,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,YAAY,CAAC,IAAI,IAAI,YAAY,CAAC;IAC3D,MAAM,kBAAkB,GAAG,YAAY,CAAC,EAAY,CAAC;IACrD,MAAM,kBAAkB,GAAG,IAAA,iBAAS,EAAC,kBAAkB,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC;IAEhD,wEAAwE;IACxE,uDAAuD;IACvD,MAAM,IAAA,qDAAkC,EAAC,IAAI,CAAC,CAAC;IAC/C,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/nx-plugin/src/py/agent/mcp-connection/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAQoB;AACpB,uFAQ0D;AAC1D,4CAAiE;AACjE,kDAA6D;AAC7D,oDAAyE;AACzE,gDAAiD;AACjD,0CAK2B;AAC3B,0CAG2B;AAGd,QAAA,sCAAsC,GACjD,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,6BAA6B,GAAG,KAAK,EAChD,IAAU,EACV,OAA4C,EAChB,EAAE;IAC9B,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IAEF,MAAM,c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e,EACf,aAAa,CACd,CAAC;IACJ,CAAC;IAED,6EAA6E;IAC7E,IAAA,sCAAiC,EAC/B,IAAI,EACJ,aAAa,CAAC,IAAI,EAClB,0BAA0B,CAC3B,CAAC;IAEF,4CAA4C;IAC5C,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,IAAI,OAAO,CAAC;IACjD,MAAM,oBAAoB,GAAG,GAAG,SAAS,cAAc,CAAC;IACxD,MAAM,uBAAuB,GAAG,GAAG,gBAAgB,cAAc,CAAC;IAElE,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAClD,IAAA,sCAAiC,EAAC,aAAa,EAAE,oBAAoB,EAAE;YACrE,QAAQ,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;YAC9B,MAAM,EAAE,uBAAuB;SAChC,CAAC,CAAC;QACH,IAAA,mCAA0B,EAAC,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE;QAC1C,8CAAsC;KACvC,CAAC,CAAC;IAEH,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAC;AA9IW,QAAA,6BAA6B,iCA8IxC;AAEF,kBAAe,qCAA6B,CAAC"}
|
|
@@ -191,7 +191,10 @@ class LoggerRouteHandler(APIRoute):
|
|
|
191
191
|
|
|
192
192
|
app.router.route_class = LoggerRouteHandler
|
|
193
193
|
",
|
|
194
|
-
"apps/test_api/proj_test_api/main.py": "import
|
|
194
|
+
"apps/test_api/proj_test_api/main.py": "from typing import Annotated
|
|
195
|
+
|
|
196
|
+
import uvicorn
|
|
197
|
+
from fastapi import Query
|
|
195
198
|
from pydantic import BaseModel
|
|
196
199
|
|
|
197
200
|
from .init import app, tracer
|
|
@@ -203,7 +206,7 @@ class EchoOutput(BaseModel):
|
|
|
203
206
|
|
|
204
207
|
@app.get("/echo")
|
|
205
208
|
@tracer.capture_method
|
|
206
|
-
def echo(message: str) -> EchoOutput:
|
|
209
|
+
def echo(message: Annotated[str, Query(max_length=1024)]) -> EchoOutput:
|
|
207
210
|
return EchoOutput(message=f"{message}")
|
|
208
211
|
|
|
209
212
|
|
|
@@ -253,6 +256,7 @@ import {
|
|
|
253
256
|
HttpMethod,
|
|
254
257
|
HttpStage,
|
|
255
258
|
LogGroupLogDestination,
|
|
259
|
+
ThrottleSettings,
|
|
256
260
|
} from 'aws-cdk-lib/aws-apigatewayv2';
|
|
257
261
|
import { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
258
262
|
import { suppressRules } from '../checkov.js';
|
|
@@ -279,6 +283,12 @@ export interface HttpApiProps<
|
|
|
279
283
|
* Map of operation names to their API Gateway integrations
|
|
280
284
|
*/
|
|
281
285
|
readonly integrations: TIntegrations;
|
|
286
|
+
/**
|
|
287
|
+
* Default throttling limits applied to the API's default stage.
|
|
288
|
+
*
|
|
289
|
+
* @default { rateLimit: 10000, burstLimit: 5000 }
|
|
290
|
+
*/
|
|
291
|
+
readonly throttle?: ThrottleSettings;
|
|
282
292
|
}
|
|
283
293
|
|
|
284
294
|
/**
|
|
@@ -312,6 +322,7 @@ export class HttpApi<
|
|
|
312
322
|
apiName,
|
|
313
323
|
operations,
|
|
314
324
|
integrations,
|
|
325
|
+
throttle = { rateLimit: 10000, burstLimit: 5000 },
|
|
315
326
|
...props
|
|
316
327
|
}: HttpApiProps<TIntegrations, TOperation>,
|
|
317
328
|
) {
|
|
@@ -339,6 +350,7 @@ export class HttpApi<
|
|
|
339
350
|
this.defaultStage = new HttpStage(this, 'DefaultStage', {
|
|
340
351
|
httpApi: this.api,
|
|
341
352
|
autoDeploy: true,
|
|
353
|
+
throttle,
|
|
342
354
|
accessLogSettings: {
|
|
343
355
|
destination: new LogGroupLogDestination(accessLogGroup),
|
|
344
356
|
},
|
|
@@ -1062,6 +1074,7 @@ import {
|
|
|
1062
1074
|
RestApiProps as _RestApiProps,
|
|
1063
1075
|
IResource,
|
|
1064
1076
|
Stage,
|
|
1077
|
+
ThrottleSettings,
|
|
1065
1078
|
} from 'aws-cdk-lib/aws-apigateway';
|
|
1066
1079
|
import { IAspect, RemovalPolicy } from 'aws-cdk-lib';
|
|
1067
1080
|
import {
|
|
@@ -1108,6 +1121,12 @@ export interface RestApiProps<
|
|
|
1108
1121
|
* @default true
|
|
1109
1122
|
*/
|
|
1110
1123
|
readonly enableWaf?: boolean;
|
|
1124
|
+
/**
|
|
1125
|
+
* Default throttling limits applied to all methods on the API's default stage.
|
|
1126
|
+
*
|
|
1127
|
+
* @default { rateLimit: 10000, burstLimit: 5000 }
|
|
1128
|
+
*/
|
|
1129
|
+
readonly throttle?: ThrottleSettings;
|
|
1111
1130
|
}
|
|
1112
1131
|
|
|
1113
1132
|
/**
|
|
@@ -1142,6 +1161,7 @@ export class RestApi<
|
|
|
1142
1161
|
operations,
|
|
1143
1162
|
integrations,
|
|
1144
1163
|
enableWaf = true,
|
|
1164
|
+
throttle = { rateLimit: 10000, burstLimit: 5000 },
|
|
1145
1165
|
...props
|
|
1146
1166
|
}: RestApiProps<TIntegrations, TOperation>,
|
|
1147
1167
|
) {
|
|
@@ -1149,7 +1169,21 @@ export class RestApi<
|
|
|
1149
1169
|
this.integrations = integrations;
|
|
1150
1170
|
|
|
1151
1171
|
// Create the API Gateway REST API
|
|
1152
|
-
this.api = new _RestApi(this, 'Api',
|
|
1172
|
+
this.api = new _RestApi(this, 'Api', {
|
|
1173
|
+
...props,
|
|
1174
|
+
deployOptions: {
|
|
1175
|
+
...props.deployOptions,
|
|
1176
|
+
methodOptions: {
|
|
1177
|
+
...props.deployOptions?.methodOptions,
|
|
1178
|
+
// Default throttling applied to all resource paths and methods
|
|
1179
|
+
'/*/*': {
|
|
1180
|
+
throttlingRateLimit: throttle.rateLimit,
|
|
1181
|
+
throttlingBurstLimit: throttle.burstLimit,
|
|
1182
|
+
...props.deployOptions?.methodOptions?.['/*/*'],
|
|
1183
|
+
},
|
|
1184
|
+
},
|
|
1185
|
+
},
|
|
1186
|
+
});
|
|
1153
1187
|
|
|
1154
1188
|
if (enableWaf) {
|
|
1155
1189
|
this.webAcl = new CfnWebACL(this, 'WebAcl', {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
from typing import Annotated
|
|
2
|
+
|
|
1
3
|
import uvicorn
|
|
4
|
+
from fastapi import Query
|
|
2
5
|
from pydantic import BaseModel
|
|
3
6
|
|
|
4
7
|
from .init import app, tracer
|
|
@@ -10,7 +13,7 @@ class EchoOutput(BaseModel):
|
|
|
10
13
|
|
|
11
14
|
@app.get("/echo")
|
|
12
15
|
@tracer.capture_method
|
|
13
|
-
def echo(message: str) -> EchoOutput:
|
|
16
|
+
def echo(message: Annotated[str, Query(max_length=1024)]) -> EchoOutput:
|
|
14
17
|
return EchoOutput(message=f"{message}")
|
|
15
18
|
|
|
16
19
|
|
|
@@ -412,14 +412,19 @@ resource "null_resource" "docker_publish" {
|
|
|
412
412
|
provisioner "local-exec" {
|
|
413
413
|
command = <<-EOT
|
|
414
414
|
# Get ECR login token
|
|
415
|
-
aws ecr get-login-password --region
|
|
415
|
+
aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$REPOSITORY_URL"
|
|
416
416
|
|
|
417
417
|
# Tag the image
|
|
418
|
-
docker tag
|
|
418
|
+
docker tag "$DOCKER_IMAGE_TAG" "$REPOSITORY_URL:latest"
|
|
419
419
|
|
|
420
420
|
# Push the image
|
|
421
|
-
docker push
|
|
421
|
+
docker push "$REPOSITORY_URL:latest"
|
|
422
422
|
EOT
|
|
423
|
+
environment = {
|
|
424
|
+
AWS_REGION = local.aws_region
|
|
425
|
+
REPOSITORY_URL = self.triggers.repository_url
|
|
426
|
+
DOCKER_IMAGE_TAG = self.triggers.docker_image_tag
|
|
427
|
+
}
|
|
423
428
|
}
|
|
424
429
|
|
|
425
430
|
depends_on = [aws_ecr_repository_policy.agent_core_ecr_policy]
|
|
@@ -481,10 +486,11 @@ resource "null_resource" "runtime_ready" {
|
|
|
481
486
|
uv run --with boto3 python -c "
|
|
482
487
|
import boto3
|
|
483
488
|
import json
|
|
489
|
+
import os
|
|
484
490
|
import time
|
|
485
491
|
import uuid
|
|
486
492
|
|
|
487
|
-
runtime_arn =
|
|
493
|
+
runtime_arn = os.environ['RUNTIME_ARN']
|
|
488
494
|
client = boto3.client('bedrock-agentcore')
|
|
489
495
|
initialize_request = json.dumps({
|
|
490
496
|
'jsonrpc': '2.0',
|
|
@@ -516,6 +522,9 @@ while True:
|
|
|
516
522
|
print(f'Runtime {runtime_arn} is serving MCP')
|
|
517
523
|
"
|
|
518
524
|
EOT
|
|
525
|
+
environment = {
|
|
526
|
+
RUNTIME_ARN = self.triggers.runtime_arn
|
|
527
|
+
}
|
|
519
528
|
}
|
|
520
529
|
}
|
|
521
530
|
|
|
@@ -14,6 +14,11 @@ resource "null_resource" "print_info" {
|
|
|
14
14
|
# }
|
|
15
15
|
|
|
16
16
|
provisioner "local-exec" {
|
|
17
|
-
command = "echo
|
|
17
|
+
command = "echo \"AWS Region: $AWS_REGION, AWS Account: $ACCOUNT_ID, Environment: $ENVIRONMENT\""
|
|
18
|
+
environment = {
|
|
19
|
+
AWS_REGION = local.aws_region
|
|
20
|
+
ACCOUNT_ID = local.account_id
|
|
21
|
+
ENVIRONMENT = var.environment
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
}
|
|
@@ -281,7 +281,7 @@ import { EchoInputSchema, EchoOutputSchema } from '../schema/index.js';
|
|
|
281
281
|
export const echo = publicProcedure
|
|
282
282
|
.input(EchoInputSchema)
|
|
283
283
|
.output(EchoOutputSchema)
|
|
284
|
-
.query((opts) => ({
|
|
284
|
+
.query((opts) => ({ message: opts.input.message }));
|
|
285
285
|
"
|
|
286
286
|
`;
|
|
287
287
|
|
|
@@ -303,13 +303,13 @@ exports[`trpc backend generator > should generate the project > apps/test-api/sr
|
|
|
303
303
|
"import { z } from 'zod';
|
|
304
304
|
|
|
305
305
|
export const EchoInputSchema = z.object({
|
|
306
|
-
message: z.string(),
|
|
306
|
+
message: z.string().max(1024),
|
|
307
307
|
});
|
|
308
308
|
|
|
309
309
|
export type IEchoInput = z.TypeOf<typeof EchoInputSchema>;
|
|
310
310
|
|
|
311
311
|
export const EchoOutputSchema = z.object({
|
|
312
|
-
|
|
312
|
+
message: z.string().max(1024),
|
|
313
313
|
});
|
|
314
314
|
|
|
315
315
|
export type IEchoOutput = z.TypeOf<typeof EchoOutputSchema>;
|
|
@@ -1206,6 +1206,7 @@ import {
|
|
|
1206
1206
|
HttpMethod,
|
|
1207
1207
|
HttpStage,
|
|
1208
1208
|
LogGroupLogDestination,
|
|
1209
|
+
ThrottleSettings,
|
|
1209
1210
|
} from 'aws-cdk-lib/aws-apigatewayv2';
|
|
1210
1211
|
import { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
1211
1212
|
import { suppressRules } from '../checkov.js';
|
|
@@ -1232,6 +1233,12 @@ export interface HttpApiProps<
|
|
|
1232
1233
|
* Map of operation names to their API Gateway integrations
|
|
1233
1234
|
*/
|
|
1234
1235
|
readonly integrations: TIntegrations;
|
|
1236
|
+
/**
|
|
1237
|
+
* Default throttling limits applied to the API's default stage.
|
|
1238
|
+
*
|
|
1239
|
+
* @default { rateLimit: 10000, burstLimit: 5000 }
|
|
1240
|
+
*/
|
|
1241
|
+
readonly throttle?: ThrottleSettings;
|
|
1235
1242
|
}
|
|
1236
1243
|
|
|
1237
1244
|
/**
|
|
@@ -1265,6 +1272,7 @@ export class HttpApi<
|
|
|
1265
1272
|
apiName,
|
|
1266
1273
|
operations,
|
|
1267
1274
|
integrations,
|
|
1275
|
+
throttle = { rateLimit: 10000, burstLimit: 5000 },
|
|
1268
1276
|
...props
|
|
1269
1277
|
}: HttpApiProps<TIntegrations, TOperation>,
|
|
1270
1278
|
) {
|
|
@@ -1292,6 +1300,7 @@ export class HttpApi<
|
|
|
1292
1300
|
this.defaultStage = new HttpStage(this, 'DefaultStage', {
|
|
1293
1301
|
httpApi: this.api,
|
|
1294
1302
|
autoDeploy: true,
|
|
1303
|
+
throttle,
|
|
1295
1304
|
accessLogSettings: {
|
|
1296
1305
|
destination: new LogGroupLogDestination(accessLogGroup),
|
|
1297
1306
|
},
|
|
@@ -2073,6 +2082,7 @@ import {
|
|
|
2073
2082
|
RestApiProps as _RestApiProps,
|
|
2074
2083
|
IResource,
|
|
2075
2084
|
Stage,
|
|
2085
|
+
ThrottleSettings,
|
|
2076
2086
|
} from 'aws-cdk-lib/aws-apigateway';
|
|
2077
2087
|
import { IAspect, RemovalPolicy } from 'aws-cdk-lib';
|
|
2078
2088
|
import {
|
|
@@ -2119,6 +2129,12 @@ export interface RestApiProps<
|
|
|
2119
2129
|
* @default true
|
|
2120
2130
|
*/
|
|
2121
2131
|
readonly enableWaf?: boolean;
|
|
2132
|
+
/**
|
|
2133
|
+
* Default throttling limits applied to all methods on the API's default stage.
|
|
2134
|
+
*
|
|
2135
|
+
* @default { rateLimit: 10000, burstLimit: 5000 }
|
|
2136
|
+
*/
|
|
2137
|
+
readonly throttle?: ThrottleSettings;
|
|
2122
2138
|
}
|
|
2123
2139
|
|
|
2124
2140
|
/**
|
|
@@ -2153,6 +2169,7 @@ export class RestApi<
|
|
|
2153
2169
|
operations,
|
|
2154
2170
|
integrations,
|
|
2155
2171
|
enableWaf = true,
|
|
2172
|
+
throttle = { rateLimit: 10000, burstLimit: 5000 },
|
|
2156
2173
|
...props
|
|
2157
2174
|
}: RestApiProps<TIntegrations, TOperation>,
|
|
2158
2175
|
) {
|
|
@@ -2160,7 +2177,21 @@ export class RestApi<
|
|
|
2160
2177
|
this.integrations = integrations;
|
|
2161
2178
|
|
|
2162
2179
|
// Create the API Gateway REST API
|
|
2163
|
-
this.api = new _RestApi(this, 'Api',
|
|
2180
|
+
this.api = new _RestApi(this, 'Api', {
|
|
2181
|
+
...props,
|
|
2182
|
+
deployOptions: {
|
|
2183
|
+
...props.deployOptions,
|
|
2184
|
+
methodOptions: {
|
|
2185
|
+
...props.deployOptions?.methodOptions,
|
|
2186
|
+
// Default throttling applied to all resource paths and methods
|
|
2187
|
+
'/*/*': {
|
|
2188
|
+
throttlingRateLimit: throttle.rateLimit,
|
|
2189
|
+
throttlingBurstLimit: throttle.burstLimit,
|
|
2190
|
+
...props.deployOptions?.methodOptions?.['/*/*'],
|
|
2191
|
+
},
|
|
2192
|
+
},
|
|
2193
|
+
},
|
|
2194
|
+
});
|
|
2164
2195
|
|
|
2165
2196
|
if (enableWaf) {
|
|
2166
2197
|
this.webAcl = new CfnWebACL(this, 'WebAcl', {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
export const EchoInputSchema = z.object({
|
|
4
|
-
message: z.string(),
|
|
4
|
+
message: z.string().max(1024),
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
export type IEchoInput = z.TypeOf<typeof EchoInputSchema>;
|
|
8
8
|
|
|
9
9
|
export const EchoOutputSchema = z.object({
|
|
10
|
-
|
|
10
|
+
message: z.string().max(1024),
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
export type IEchoOutput = z.TypeOf<typeof EchoOutputSchema>;
|
|
@@ -1104,14 +1104,19 @@ resource "null_resource" "docker_publish" {
|
|
|
1104
1104
|
provisioner "local-exec" {
|
|
1105
1105
|
command = <<-EOT
|
|
1106
1106
|
# Get ECR login token
|
|
1107
|
-
aws ecr get-login-password --region
|
|
1107
|
+
aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$REPOSITORY_URL"
|
|
1108
1108
|
|
|
1109
1109
|
# Tag the image
|
|
1110
|
-
docker tag
|
|
1110
|
+
docker tag "$DOCKER_IMAGE_TAG" "$REPOSITORY_URL:latest"
|
|
1111
1111
|
|
|
1112
1112
|
# Push the image
|
|
1113
|
-
docker push
|
|
1113
|
+
docker push "$REPOSITORY_URL:latest"
|
|
1114
1114
|
EOT
|
|
1115
|
+
environment = {
|
|
1116
|
+
AWS_REGION = local.aws_region
|
|
1117
|
+
REPOSITORY_URL = self.triggers.repository_url
|
|
1118
|
+
DOCKER_IMAGE_TAG = self.triggers.docker_image_tag
|
|
1119
|
+
}
|
|
1115
1120
|
}
|
|
1116
1121
|
|
|
1117
1122
|
depends_on = [aws_ecr_repository_policy.agent_core_ecr_policy]
|
|
@@ -1173,10 +1178,11 @@ resource "null_resource" "runtime_ready" {
|
|
|
1173
1178
|
uv run --with boto3 python -c "
|
|
1174
1179
|
import boto3
|
|
1175
1180
|
import json
|
|
1181
|
+
import os
|
|
1176
1182
|
import time
|
|
1177
1183
|
import uuid
|
|
1178
1184
|
|
|
1179
|
-
runtime_arn =
|
|
1185
|
+
runtime_arn = os.environ['RUNTIME_ARN']
|
|
1180
1186
|
client = boto3.client('bedrock-agentcore')
|
|
1181
1187
|
initialize_request = json.dumps({
|
|
1182
1188
|
'jsonrpc': '2.0',
|
|
@@ -1208,6 +1214,9 @@ while True:
|
|
|
1208
1214
|
print(f'Runtime {runtime_arn} is serving MCP')
|
|
1209
1215
|
"
|
|
1210
1216
|
EOT
|
|
1217
|
+
environment = {
|
|
1218
|
+
RUNTIME_ARN = self.triggers.runtime_arn
|
|
1219
|
+
}
|
|
1211
1220
|
}
|
|
1212
1221
|
}
|
|
1213
1222
|
|
|
@@ -1560,7 +1569,7 @@ const agent = withSessionId(getAgent);
|
|
|
1560
1569
|
|
|
1561
1570
|
export const appRouter = router({
|
|
1562
1571
|
invoke: publicProcedure
|
|
1563
|
-
.input(z.object({ message: z.string() }))
|
|
1572
|
+
.input(z.object({ message: z.string().max(100000) }))
|
|
1564
1573
|
.output(
|
|
1565
1574
|
zAsyncIterable({
|
|
1566
1575
|
yield: z.string(),
|