@aws/nx-plugin 1.0.0-rc.22 → 1.0.0-rc.24
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/LICENSE-THIRD-PARTY +2088 -971
- package/package.json +25 -10
- package/src/agentcore-gateway/attach-upstream.d.ts +7 -7
- package/src/agentcore-gateway/attach-upstream.js +19 -22
- package/src/agentcore-gateway/attach-upstream.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +3 -3
- package/src/agentcore-gateway/gateway-connection/generator.js +42 -45
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.js +6 -0
- package/src/agentcore-gateway/gateway-connection/schema.d.js.map +1 -0
- package/src/agentcore-gateway/generator.js +89 -72
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +2 -2
- package/src/agentcore-gateway/mcp-connection/generator.js +24 -30
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.js +6 -0
- package/src/agentcore-gateway/mcp-connection/schema.d.js.map +1 -0
- package/src/agentcore-gateway/schema.d.js +6 -0
- package/src/agentcore-gateway/schema.d.js.map +1 -0
- package/src/bin/aws-nx-mcp.js +14 -0
- package/src/bin/aws-nx-mcp.js.map +1 -0
- package/src/connection/{agent-serve-local.d.ts → agent-local-dev.d.ts} +5 -5
- package/src/connection/agent-local-dev.js +42 -0
- package/src/connection/agent-local-dev.js.map +1 -0
- package/src/connection/agent-runtime-config.js +9 -14
- package/src/connection/agent-runtime-config.js.map +1 -1
- package/src/connection/generator.js +262 -207
- package/src/connection/generator.js.map +1 -1
- package/src/connection/{serve-local.d.ts → local-dev.d.ts} +3 -3
- package/src/connection/local-dev.js +37 -0
- package/src/connection/local-dev.js.map +1 -0
- package/src/connection/schema.d.js +6 -0
- package/src/connection/schema.d.js.map +1 -0
- package/src/index.js +2 -5
- package/src/index.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +4 -26
- package/src/infra/app/generator.js +133 -123
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.js +6 -0
- package/src/infra/app/schema.d.js.map +1 -0
- package/src/license/config-types.js +5 -3
- package/src/license/config-types.js.map +1 -1
- package/src/license/config.d.ts +1 -1
- package/src/license/config.js +267 -242
- package/src/license/config.js.map +1 -1
- package/src/license/dependency-check/check.js +51 -46
- package/src/license/dependency-check/check.js.map +1 -1
- package/src/license/dependency-check/collectors/collector.js +41 -71
- package/src/license/dependency-check/collectors/collector.js.map +1 -1
- package/src/license/dependency-check/collectors/npm-collector.js +34 -41
- package/src/license/dependency-check/collectors/npm-collector.js.map +1 -1
- package/src/license/dependency-check/collectors/python-collector.js +55 -62
- package/src/license/dependency-check/collectors/python-collector.js.map +1 -1
- package/src/license/dependency-check/evaluator.js +40 -68
- package/src/license/dependency-check/evaluator.js.map +1 -1
- package/src/license/dependency-check/executor.js +30 -22
- package/src/license/dependency-check/executor.js.map +1 -1
- package/src/license/dependency-check/pre-approved.js +949 -336
- package/src/license/dependency-check/pre-approved.js.map +1 -1
- package/src/license/dependency-check/types.js +2 -3
- package/src/license/dependency-check/types.js.map +1 -1
- package/src/license/generator.js +55 -60
- package/src/license/generator.js.map +1 -1
- package/src/license/index.js +3 -9
- package/src/license/index.js.map +1 -1
- package/src/license/known-exceptions.js +14 -13
- package/src/license/known-exceptions.js.map +1 -1
- package/src/license/schema.d.js +6 -0
- package/src/license/schema.d.js.map +1 -0
- package/src/license/sync/generator.js +94 -119
- package/src/license/sync/generator.js.map +1 -1
- package/src/license/sync/project-file-sync.js +28 -35
- package/src/license/sync/project-file-sync.js.map +1 -1
- package/src/mcp-server/generator-info.js +130 -160
- package/src/mcp-server/generator-info.js.map +1 -1
- package/src/mcp-server/guide-pipeline.js +184 -206
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/guide-render.js +10 -25
- package/src/mcp-server/guide-render.js.map +1 -1
- package/src/mcp-server/index.js +6 -10
- package/src/mcp-server/index.js.map +1 -1
- package/src/mcp-server/mdx-ast.js +39 -57
- package/src/mcp-server/mdx-ast.js.map +1 -1
- package/src/mcp-server/option-filter.js +33 -47
- package/src/mcp-server/option-filter.js.map +1 -1
- package/src/mcp-server/schema-registry.js +27 -40
- package/src/mcp-server/schema-registry.js.map +1 -1
- package/src/mcp-server/schema.js +9 -7
- package/src/mcp-server/schema.js.map +1 -1
- package/src/mcp-server/server.js +20 -24
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/create-workspace-command.js +23 -24
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/mcp-server/tools/general-guidance.js +28 -25
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/mcp-server/tools/generator-guide.js +29 -37
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/mcp-server/tools/list-generators.js +19 -25
- package/src/mcp-server/tools/list-generators.js.map +1 -1
- package/src/open-api/ts-client/generator.js +16 -26
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-client/schema.d.js +6 -0
- package/src/open-api/ts-client/schema.d.js.map +1 -0
- package/src/open-api/ts-hooks/generator.js +13 -21
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/open-api/ts-hooks/schema.d.js +6 -0
- package/src/open-api/ts-hooks/schema.d.js.map +1 -0
- package/src/open-api/ts-metadata/generator.js +12 -20
- package/src/open-api/ts-metadata/generator.js.map +1 -1
- package/src/open-api/ts-metadata/schema.d.js +6 -0
- package/src/open-api/ts-metadata/schema.d.js.map +1 -0
- package/src/open-api/utils/codegen-data/languages.js +42 -60
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data/types.js +31 -30
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.js +253 -269
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +242 -241
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parse.js +8 -14
- package/src/open-api/utils/parse.js.map +1 -1
- package/src/open-api/utils/refs.js +12 -22
- package/src/open-api/utils/refs.js.map +1 -1
- package/src/open-api/utils/types.js +5 -2
- package/src/open-api/utils/types.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +31 -6
- package/src/preset/generator.d.ts +1 -1
- package/src/preset/generator.js +130 -112
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.js +6 -0
- package/src/preset/schema.d.js.map +1 -0
- package/src/preset/schema.d.ts +0 -1
- package/src/preset/schema.json +0 -5
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +304 -0
- package/src/py/agent/__snapshots__/{generator.spec.ts.snap → generator.frameworks.spec.ts.snap} +18 -845
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +535 -0
- package/src/py/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +1 -2
- package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client_strands.py.template +1 -1
- package/src/py/agent/a2a-connection/files/langchain/agent-connection/app/__targetAgentSnakeCase___client_langchain.py.template +1 -1
- package/src/py/agent/a2a-connection/generator.js +70 -75
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.js +8 -0
- package/src/py/agent/a2a-connection/schema.d.js.map +1 -0
- package/src/py/agent/files/ag-ui-langchain/main.py.template +10 -0
- package/src/py/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +6 -8
- package/src/py/agent/gateway-connection/files/agent-connection/app/__gatewaySnakeCase___client_strands.py.template +3 -3
- package/src/py/agent/gateway-connection/files/langchain/agent-connection/app/__gatewaySnakeCase___client_langchain.py.template +3 -3
- package/src/py/agent/gateway-connection/generator.js +61 -58
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.js +6 -0
- package/src/py/agent/gateway-connection/schema.d.js.map +1 -0
- package/src/py/agent/generator.js +227 -194
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +5 -12
- package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client_strands.py.template +1 -1
- package/src/py/agent/mcp-connection/files/langchain/agent-connection/app/__mcpServerSnakeCase___client_langchain.py.template +1 -1
- package/src/py/agent/mcp-connection/generator.js +53 -52
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.js +8 -0
- package/src/py/agent/mcp-connection/schema.d.js.map +1 -0
- package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +3 -2
- package/src/py/agent/react-connection/generator.js +51 -58
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/{serve-local.d.ts → local-dev.d.ts} +4 -4
- package/src/py/agent/react-connection/local-dev.js +36 -0
- package/src/py/agent/react-connection/local-dev.js.map +1 -0
- package/src/py/agent/react-connection/schema.d.js +8 -0
- package/src/py/agent/react-connection/schema.d.js.map +1 -0
- package/src/py/agent/schema.d.js +6 -0
- package/src/py/agent/schema.d.js.map +1 -0
- package/src/py/api/generator.js +12 -12
- package/src/py/api/generator.js.map +1 -1
- package/src/py/api/schema.d.js +6 -0
- package/src/py/api/schema.d.js.map +1 -0
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +68 -28
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/dynamodb/agent-connection/generator.js +27 -29
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.js +8 -0
- package/src/py/dynamodb/agent-connection/schema.d.js.map +1 -0
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/py/dynamodb/fast-api-connection/generator.js +26 -28
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/schema.d.js +8 -0
- package/src/py/dynamodb/fast-api-connection/schema.d.js.map +1 -0
- package/src/py/dynamodb/files/__name__/client.py.template +5 -5
- package/src/py/dynamodb/files/__name__/entities/base.py.template +2 -2
- package/src/py/dynamodb/files/config.json.template +1 -1
- package/src/py/dynamodb/generator.js +63 -62
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/dynamodb/mcp-server-connection/generator.js +27 -29
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.js +8 -0
- package/src/py/dynamodb/mcp-server-connection/schema.d.js.map +1 -0
- package/src/py/dynamodb/schema.d.js +6 -0
- package/src/py/dynamodb/schema.d.js.map +1 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +45 -4632
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +4833 -0
- package/src/py/fast-api/generator.js +79 -85
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/__snapshots__/generator.spec.ts.snap +3 -2
- package/src/py/fast-api/react/generator.js +22 -24
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/react/open-api.js +28 -29
- package/src/py/fast-api/react/open-api.js.map +1 -1
- package/src/py/fast-api/react/schema.d.js +6 -0
- package/src/py/fast-api/react/schema.d.js.map +1 -0
- package/src/py/fast-api/schema.d.js +6 -0
- package/src/py/fast-api/schema.d.js.map +1 -0
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/py/lambda-function/generator.js +57 -58
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.js +6 -0
- package/src/py/lambda-function/schema.d.js.map +1 -0
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/mcp-server/generator.js +149 -131
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.js +6 -0
- package/src/py/mcp-server/schema.d.js.map +1 -0
- package/src/py/project/generator.d.ts +14 -1
- package/src/py/project/generator.js +137 -88
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.d.js +6 -0
- package/src/py/project/schema.d.js.map +1 -0
- package/src/sdk/agentcore-gateway.d.ts +6 -0
- package/src/sdk/agentcore-gateway.js +7 -0
- package/src/sdk/agentcore-gateway.js.map +1 -0
- package/src/sdk/connection.d.ts +6 -0
- package/src/sdk/connection.js +6 -0
- package/src/sdk/connection.js.map +1 -0
- package/{sdk → src/sdk}/license.d.ts +4 -4
- package/src/sdk/license.js +7 -0
- package/src/sdk/license.js.map +1 -0
- package/src/sdk/open-api.d.ts +10 -0
- package/src/sdk/open-api.js +8 -0
- package/src/sdk/open-api.js.map +1 -0
- package/src/sdk/py.d.ts +14 -0
- package/src/sdk/py.js +10 -0
- package/src/sdk/py.js.map +1 -0
- package/src/sdk/terraform.d.ts +6 -0
- package/src/sdk/terraform.js +7 -0
- package/src/sdk/terraform.js.map +1 -0
- package/src/sdk/ts.d.ts +33 -0
- package/src/sdk/ts.js +35 -0
- package/src/sdk/ts.js.map +1 -0
- package/{sdk → src/sdk}/utils/ast.d.ts +2 -2
- package/src/sdk/utils/ast.js +7 -0
- package/src/sdk/utils/ast.js.map +1 -0
- package/{sdk → src/sdk}/utils/format.d.ts +1 -1
- package/src/sdk/utils/format.js +6 -0
- package/src/sdk/utils/format.js.map +1 -0
- package/{sdk → src/sdk}/utils/test.d.ts +1 -1
- package/src/sdk/utils/test.js +6 -0
- package/src/sdk/utils/test.js.map +1 -0
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +2 -8
- package/src/smithy/project/files/build.Dockerfile.template +1 -4
- package/src/smithy/project/generator.js +44 -42
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/project/schema.d.js +6 -0
- package/src/smithy/project/schema.d.js.map +1 -0
- package/src/smithy/react-connection/generator.js +35 -46
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/react-connection/schema.d.js +6 -0
- package/src/smithy/react-connection/schema.d.js.map +1 -0
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +395 -72
- package/src/smithy/ts/api/generator.js +121 -111
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.js +6 -0
- package/src/smithy/ts/api/schema.d.js.map +1 -0
- package/src/terraform/project/files/application/src/providers.tf.template +1 -1
- package/src/terraform/project/generator.js +141 -103
- package/src/terraform/project/generator.js.map +1 -1
- package/src/terraform/project/schema.d.js +9 -0
- package/src/terraform/project/schema.d.js.map +1 -0
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +336 -92
- package/src/trpc/backend/generator.js +93 -86
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.js +6 -0
- package/src/trpc/backend/schema.d.js.map +1 -0
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/trpc/react/generator.js +59 -58
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.d.js +6 -0
- package/src/trpc/react/schema.d.js.map +1 -0
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +11 -11
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +1 -1
- package/src/ts/agent/a2a-connection/generator.js +58 -54
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.js +8 -0
- package/src/ts/agent/a2a-connection/schema.d.js.map +1 -0
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +3 -3
- package/src/ts/agent/gateway-connection/generator.js +57 -52
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.js +6 -0
- package/src/ts/agent/gateway-connection/schema.d.js.map +1 -0
- package/src/ts/agent/generator.js +165 -136
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +1 -1
- package/src/ts/agent/mcp-connection/generator.js +48 -46
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.js +8 -0
- package/src/ts/agent/mcp-connection/schema.d.js.map +1 -0
- package/src/ts/agent/react-connection/generator.js +79 -79
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/{serve-local.d.ts → local-dev.d.ts} +2 -2
- package/src/ts/agent/react-connection/local-dev.js +17 -0
- package/src/ts/agent/react-connection/local-dev.js.map +1 -0
- package/src/ts/agent/react-connection/schema.d.js +8 -0
- package/src/ts/agent/react-connection/schema.d.js.map +1 -0
- package/src/ts/agent/schema.d.js +6 -0
- package/src/ts/agent/schema.d.js.map +1 -0
- package/src/ts/api/generator.js +16 -18
- package/src/ts/api/generator.js.map +1 -1
- package/src/ts/api/schema.d.js +6 -0
- package/src/ts/api/schema.d.js.map +1 -0
- package/src/ts/astro-docs/__snapshots__/generator.spec.ts.snap +8 -8
- package/src/ts/astro-docs/generator.js +59 -48
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/astro-docs/schema.d.js +6 -0
- package/src/ts/astro-docs/schema.d.js.map +1 -0
- package/src/ts/docs/generator.js +10 -10
- package/src/ts/docs/generator.js.map +1 -1
- package/src/ts/docs/schema.d.js +6 -0
- package/src/ts/docs/schema.d.js.map +1 -0
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +68 -30
- package/src/ts/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/ts/dynamodb/agent-connection/generator.js +21 -23
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/agent-connection/schema.d.js.map +1 -0
- package/src/ts/dynamodb/files/config.json.template +1 -1
- package/src/ts/dynamodb/files/src/client.ts.template +7 -7
- package/src/ts/dynamodb/generator.js +64 -63
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/ts/dynamodb/mcp-server-connection/generator.js +21 -23
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.d.js.map +1 -0
- package/src/ts/dynamodb/schema.d.js +6 -0
- package/src/ts/dynamodb/schema.d.js.map +1 -0
- package/src/ts/dynamodb/smithy-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/dynamodb/smithy-connection/generator.js +20 -22
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/smithy-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/smithy-connection/schema.d.js.map +1 -0
- package/src/ts/dynamodb/trpc-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/dynamodb/trpc-connection/generator.js +20 -22
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/trpc-connection/schema.d.js.map +1 -0
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/lambda-function/generator.js +55 -55
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/io.js +83 -52
- package/src/ts/lambda-function/io.js.map +1 -1
- package/src/ts/lambda-function/schema.d.js +6 -0
- package/src/ts/lambda-function/schema.d.js.map +1 -0
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +23 -36
- package/src/ts/lib/biome.js +37 -37
- package/src/ts/lib/biome.js.map +1 -1
- package/src/ts/lib/generator.js +75 -77
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.js +6 -0
- package/src/ts/lib/schema.d.js.map +1 -0
- package/src/ts/lib/ts-project-utils.js +65 -70
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/types.js +5 -2
- package/src/ts/lib/types.js.map +1 -1
- package/src/ts/lib/vitest.js +29 -26
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/ts/mcp-server/generator.js +157 -138
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.js +6 -0
- package/src/ts/mcp-server/schema.d.js.map +1 -0
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +14 -9
- package/src/ts/nx-generator/files/local/generator.ts.template +3 -3
- package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +4 -4
- package/src/ts/nx-generator/generator.js +84 -83
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-generator/schema.d.js +6 -0
- package/src/ts/nx-generator/schema.d.js.map +1 -0
- package/src/ts/nx-plugin/__snapshots__/generator.spec.ts.snap +30 -18
- package/src/ts/nx-plugin/files/mcp-server/server.ts.template +5 -5
- package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/tools/general-guidance.ts.template +1 -1
- package/src/ts/nx-plugin/files/mcp-server/tools/generator-guide.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/tools/list-generators.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +3 -3
- package/src/ts/nx-plugin/generator.js +49 -48
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/schema.d.js +9 -0
- package/src/ts/nx-plugin/schema.d.js.map +1 -0
- package/src/ts/nx-plugin/utils.js +32 -44
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +34 -30
- package/src/ts/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/rdb/agent-connection/generator.js +38 -39
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/agent-connection/schema.d.js +8 -0
- package/src/ts/rdb/agent-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/files/config.json.template +1 -1
- package/src/ts/rdb/files/prisma.config.ts.template +2 -2
- package/src/ts/rdb/files/src/prisma.ts.template +7 -7
- package/src/ts/rdb/files/src/utils.ts.template +3 -0
- package/src/ts/rdb/generator.js +130 -117
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/rdb/mcp-server-connection/generator.js +36 -37
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.js +8 -0
- package/src/ts/rdb/mcp-server-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/schema.d.js +6 -0
- package/src/ts/rdb/schema.d.js.map +1 -0
- package/src/ts/rdb/smithy-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/rdb/smithy-connection/generator.js +46 -43
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/smithy-connection/schema.d.js +8 -0
- package/src/ts/rdb/smithy-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/trpc-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/rdb/trpc-connection/generator.js +36 -31
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/schema.d.js +8 -0
- package/src/ts/rdb/trpc-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/utils.js +9 -11
- package/src/ts/rdb/utils.js.map +1 -1
- package/src/ts/react-website/agui/generator.js +69 -61
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +179 -332
- package/src/ts/react-website/app/generator.js +197 -188
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.js +6 -0
- package/src/ts/react-website/app/schema.d.js.map +1 -0
- package/src/ts/react-website/app/schema.json +6 -6
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +118 -4
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +27 -7
- package/src/ts/react-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +2 -2
- package/src/ts/react-website/cognito-auth/generator.js +60 -60
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.js +6 -0
- package/src/ts/react-website/cognito-auth/schema.d.js.map +1 -0
- package/src/ts/react-website/cognito-auth/utils.js +34 -32
- package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
- package/src/ts/react-website/runtime-config/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/react-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +2 -2
- package/src/ts/react-website/runtime-config/generator.js +29 -31
- package/src/ts/react-website/runtime-config/generator.js.map +1 -1
- package/src/ts/react-website/runtime-config/schema.d.js +6 -0
- package/src/ts/react-website/runtime-config/schema.d.js.map +1 -0
- package/src/ts/sync/generator.js +60 -59
- package/src/ts/sync/generator.js.map +1 -1
- package/src/ts/website/app/generator.js +10 -10
- package/src/ts/website/app/generator.js.map +1 -1
- package/src/ts/website/app/schema.d.js +6 -0
- package/src/ts/website/app/schema.d.js.map +1 -0
- package/src/ts/website/app/schema.json +6 -6
- package/src/ts/website/auth/generator.js +11 -11
- package/src/ts/website/auth/generator.js.map +1 -1
- package/src/ts/website/auth/schema.d.js +6 -0
- package/src/ts/website/auth/schema.d.js.map +1 -0
- package/src/utils/agent-chat/agent-chat.d.ts +1 -1
- package/src/utils/agent-chat/agent-chat.js +11 -12
- package/src/utils/agent-chat/agent-chat.js.map +1 -1
- package/src/utils/agent-chat/files/a2a/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/ag-ui/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/http-py/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/http-ts/chat.ts.template +1 -1
- package/src/utils/agent-connection/agent-connection.d.ts +9 -3
- package/src/utils/agent-connection/agent-connection.js +133 -147
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +1 -1
- package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +1 -1
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_transport.py.template +1 -1
- package/src/utils/agent-connection/files/py-core-langchain/gateway/agentcore_gateway_mcp_client_langchain.py.template +1 -1
- package/src/utils/agent-connection/files/py-core-strands/gateway/agentcore_gateway_mcp_client_strands.py.template +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js +53 -50
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +5 -5
- package/src/utils/agent-core-constructs/files/terraform/core/agentcore-gateway/gateway.tf.template +2 -2
- package/src/utils/api-constructs/api-constructs.js +30 -31
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +14 -6
- package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template +58 -0
- package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account.ts.template +82 -0
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +28 -14
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -8
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +91 -4
- package/src/utils/api-constructs/files/terraform/core/api/http/http-api/http-api.tf.template +1 -1
- package/src/utils/api-constructs/files/terraform/core/api/rest/api-gateway-account/api-gateway-account.tf.template +83 -0
- package/src/utils/api-constructs/files/terraform/core/api/rest/rest-api/rest-api.tf.template +5 -11
- package/src/utils/api-constructs/open-api-metadata.js +22 -22
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
- package/src/utils/ast/website.js +17 -19
- package/src/utils/ast/website.js.map +1 -1
- package/src/utils/ast.js +72 -97
- package/src/utils/ast.js.map +1 -1
- package/src/utils/bundle/bundle.js +50 -47
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.js +47 -26
- package/src/utils/commands.js.map +1 -1
- package/src/utils/config/index.d.ts +2 -2
- package/src/utils/config/index.js +5 -4
- package/src/utils/config/index.js.map +1 -1
- package/src/utils/config/utils.js +48 -58
- package/src/utils/config/utils.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +5 -5
- package/src/utils/connection/open-api/react.js +81 -77
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/containers.js +22 -23
- package/src/utils/containers.js.map +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js +32 -33
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
- package/src/utils/dynamodb-constructs/files/terraform/app/dynamodb/__nameKebabCase__/__nameKebabCase__.tf.template +12 -2
- package/src/utils/dynamodb-constructs/files/terraform/core/dynamodb/dynamodb.tf.template +1 -1
- package/src/utils/files/common/scripts/src/dynamodb/create-local-table.ts.template +2 -2
- package/src/utils/files/common/scripts/src/dynamodb/pull-image.ts.template +1 -1
- package/src/utils/files/common/scripts/src/dynamodb/start-container.ts.template +17 -2
- package/src/utils/files/common/scripts/src/rdb/mysql/wait-for-mysql-db.ts.template +32 -0
- package/src/utils/files/common/scripts/src/rdb/postgres/wait-for-postgres-db.ts.template +32 -0
- package/src/utils/files/common/scripts/src/rdb/{pull-image.ts.template → shared/pull-image.ts.template} +1 -1
- package/src/utils/files/common/scripts/src/rdb/{start-container.ts.template → shared/start-container.ts.template} +16 -1
- package/src/utils/files/terraform/src/core/asset-bucket/asset-bucket.tf.template +2 -2
- package/src/utils/files/terraform/src/core/runtime-config/appconfig/appconfig.tf.template +1 -1
- package/src/utils/files/terraform/src/core/runtime-config/appconfig-deployment/appconfig-deployment.tf.template +3 -3
- package/src/utils/files/terraform/src/core/runtime-config/entry/entry.tf.template +1 -1
- package/src/utils/files/terraform/src/core/runtime-config/read/read.tf.template +2 -2
- package/src/utils/files/website/hooks/sigv4/useSigV4.tsx.template +1 -1
- package/src/utils/format.js +153 -99
- package/src/utils/format.js.map +1 -1
- package/src/utils/fs.js +14 -13
- package/src/utils/fs.js.map +1 -1
- package/src/utils/function-constructs/files/terraform/app/lambda-functions/__nameKebabCase__/__nameKebabCase__.tf.template +2 -2
- package/src/utils/function-constructs/function-constructs.js +21 -26
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/generators.js +18 -20
- package/src/utils/generators.js.map +1 -1
- package/src/utils/git.js +19 -34
- package/src/utils/git.js.map +1 -1
- package/src/utils/iac-providers.js +5 -5
- package/src/utils/iac-providers.js.map +1 -1
- package/src/utils/iac.js +12 -14
- package/src/utils/iac.js.map +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +112 -2
- package/src/utils/identity-constructs/files/terraform/core/user-identity/add-callback-url/add-callback-url.tf.template +19 -6
- package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +104 -2
- package/src/utils/identity-constructs/files/terraform/core/user-identity/main.tf.template +7 -0
- package/src/utils/identity-constructs/identity-constructs.js +24 -28
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/js.js +27 -20
- package/src/utils/js.js.map +1 -1
- package/src/utils/mcp.js +34 -41
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/metrics.js +30 -45
- package/src/utils/metrics.js.map +1 -1
- package/src/utils/mock-project-graph.js +8 -12
- package/src/utils/mock-project-graph.js.map +1 -1
- package/src/utils/names.d.ts +16 -0
- package/src/utils/names.js +39 -48
- package/src/utils/names.js.map +1 -1
- package/src/utils/npm-scope.js +9 -17
- package/src/utils/npm-scope.js.map +1 -1
- package/src/utils/nx.d.ts +18 -2
- package/src/utils/nx.js +111 -74
- package/src/utils/nx.js.map +1 -1
- package/src/utils/nxlv-python.js +27 -15
- package/src/utils/nxlv-python.js.map +1 -1
- package/src/utils/object.js +5 -11
- package/src/utils/object.js.map +1 -1
- package/src/utils/paths.js +11 -15
- package/src/utils/paths.js.map +1 -1
- package/src/utils/pkg-manager.js +4 -9
- package/src/utils/pkg-manager.js.map +1 -1
- package/src/utils/pnpm-workspace.js +22 -22
- package/src/utils/pnpm-workspace.js.map +1 -1
- package/src/utils/port.js +26 -36
- package/src/utils/port.js.map +1 -1
- package/src/utils/py.d.ts +14 -1
- package/src/utils/py.js +63 -45
- package/src/utils/py.js.map +1 -1
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +3 -3
- package/src/utils/rdb-constructs/rdb-constructs.js +31 -33
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs-constants.js +16 -16
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.js +57 -54
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.js +16 -14
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-config.js +30 -31
- package/src/utils/shared-infra-config.js.map +1 -1
- package/src/utils/shared-infra-scripts.js +30 -25
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +8 -3
- package/src/utils/shared-rdb-scripts.js +21 -13
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-scripts.js +12 -17
- package/src/utils/shared-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.js +64 -60
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/test.d.ts +8 -0
- package/src/utils/test.js +33 -25
- package/src/utils/test.js.map +1 -1
- package/src/utils/toml.js +7 -15
- package/src/utils/toml.js.map +1 -1
- package/src/utils/versions.d.ts +31 -4
- package/src/utils/versions.js +40 -23
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/terraform/app/static-websites/__websiteNameKebabCase__/__websiteNameKebabCase__.tf.template +1 -1
- package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +4 -4
- package/src/utils/website-constructs/website-constructs.js +31 -30
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
- package/bin/aws-nx-mcp.js +0 -17
- package/bin/aws-nx-mcp.js.map +0 -1
- package/sdk/agentcore-gateway.d.ts +0 -6
- package/sdk/agentcore-gateway.js +0 -11
- package/sdk/agentcore-gateway.js.map +0 -1
- package/sdk/connection.d.ts +0 -6
- package/sdk/connection.js +0 -10
- package/sdk/connection.js.map +0 -1
- package/sdk/license.js +0 -14
- package/sdk/license.js.map +0 -1
- package/sdk/open-api.d.ts +0 -10
- package/sdk/open-api.js +0 -15
- package/sdk/open-api.js.map +0 -1
- package/sdk/py.d.ts +0 -14
- package/sdk/py.js +0 -18
- package/sdk/py.js.map +0 -1
- package/sdk/terraform.d.ts +0 -6
- package/sdk/terraform.js +0 -11
- package/sdk/terraform.js.map +0 -1
- package/sdk/ts.d.ts +0 -33
- package/sdk/ts.js +0 -53
- package/sdk/ts.js.map +0 -1
- package/sdk/utils/ast.js +0 -12
- package/sdk/utils/ast.js.map +0 -1
- package/sdk/utils/format.js +0 -10
- package/sdk/utils/format.js.map +0 -1
- package/sdk/utils/test.js +0 -10
- package/sdk/utils/test.js.map +0 -1
- package/src/connection/agent-serve-local.js +0 -48
- package/src/connection/agent-serve-local.js.map +0 -1
- package/src/connection/serve-local.js +0 -41
- package/src/connection/serve-local.js.map +0 -1
- package/src/py/agent/react-connection/serve-local.js +0 -38
- package/src/py/agent/react-connection/serve-local.js.map +0 -1
- package/src/ts/agent/react-connection/serve-local.js +0 -19
- package/src/ts/agent/react-connection/serve-local.js.map +0 -1
- package/src/utils/files/common/scripts/src/rdb/wait-for-db.ts.template +0 -59
- /package/src/agentcore-gateway/files/project/{serve-local.ts.template → local-dev.ts.template} +0 -0
- /package/{bin → src/bin}/aws-nx-mcp.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/api-constructs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { addStarExport } from '../ast';\nimport type { Iac } from '../iac';\nimport { addDependencyToTargetIfNotPresent } from '../nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../shared-constructs-constants';\nimport { PY_VERSIONS, terraformProviderVersions } from '../versions';\n\ninterface BackendOptions {\n type: 'trpc' | 'fastapi' | 'smithy';\n integrationPattern: 'isolated' | 'shared';\n}\n\nexport interface TrpcBackendOptions extends BackendOptions {\n type: 'trpc';\n projectAlias: string;\n bundleOutputDir: string;\n authorizerBundleOutputDir?: string;\n}\n\nexport interface FastApiBackendOptions extends BackendOptions {\n type: 'fastapi';\n moduleName: string;\n bundleOutputDir: string;\n}\n\nexport interface SmithyBackendOptions extends BackendOptions {\n type: 'smithy';\n bundleOutputDir: string;\n authorizerBundleOutputDir?: string;\n}\n\nexport interface AddApiGatewayConstructOptions {\n apiProjectName: string;\n apiNameClassName: string;\n apiNameKebabCase: string;\n constructType: 'http' | 'rest';\n backend: TrpcBackendOptions | FastApiBackendOptions | SmithyBackendOptions;\n auth: 'iam' | 'cognito' | 'custom';\n}\n\nexport const addApiGatewayInfra = async (\n tree: Tree,\n options: AddApiGatewayConstructOptions & { iac: Iac },\n) => {\n if (options.iac === 'cdk') {\n await addApiGatewayCdkConstructs(tree, options);\n } else if (options.iac === 'terraform') {\n addApiGatewayTerraformModules(tree, options);\n } else {\n throw new Error(`Unsupported iac ${options.iac}`);\n }\n\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.apiProjectName}:build`,\n );\n return config;\n },\n );\n};\n\n/**\n * Add an API CDK construct, and update the Runtime Config type to export its url\n */\nconst addApiGatewayCdkConstructs = async (\n tree: Tree,\n options: AddApiGatewayConstructOptions,\n) => {\n const generateCoreApiFile = (name: string) => {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'cdk',\n 'core',\n 'api',\n name,\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'api',\n ),\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n };\n\n // Generate relevant core CDK construct and utilities\n generateCoreApiFile(options.constructType);\n generateCoreApiFile('utils');\n if (options.backend.type === 'trpc') {\n generateCoreApiFile('trpc');\n }\n\n // Generate app specific CDK construct\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'cdk',\n 'app',\n 'apis',\n options.constructType,\n ),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'apis',\n ),\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Export app specific CDK construct\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'apis',\n 'index.ts',\n ),\n `./${options.apiNameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n './apis/index.js',\n );\n};\n\n/**\n * Add an API terraform module, and update the Runtime Config type to export its url\n */\nconst addApiGatewayTerraformModules = (\n tree: Tree,\n options: AddApiGatewayConstructOptions,\n) => {\n // Generate core terraform module\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'core',\n 'api',\n options.constructType,\n ),\n joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'core', 'api'),\n { boto3Version: PY_VERSIONS.boto3, ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Generate app specific terraform module\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'terraform',\n 'app',\n 'apis',\n options.constructType,\n ),\n joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'app', 'apis'),\n { ...options, ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","addStarExport","addDependencyToTargetIfNotPresent","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","PY_VERSIONS","terraformProviderVersions","addApiGatewayInfra","tree","options","iac","addApiGatewayCdkConstructs","addApiGatewayTerraformModules","Error","config","apiProjectName","generateCoreApiFile","name","dirname","overwriteStrategy","KeepExisting","constructType","backend","type","apiNameKebabCase","boto3Version","boto3"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SAASC,aAAa,QAAQ,YAAS;AAEvC,SAASC,iCAAiC,QAAQ,WAAQ;AAC1D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,oCAAiC;AACxC,SAASC,WAAW,EAAEC,yBAAyB,QAAQ,iBAAc;AAmCrE,OAAO,MAAMC,qBAAqB,OAChCC,MACAC;IAEA,IAAIA,QAAQC,GAAG,KAAK,OAAO;QACzB,MAAMC,2BAA2BH,MAAMC;IACzC,OAAO,IAAIA,QAAQC,GAAG,KAAK,aAAa;QACtCE,8BAA8BJ,MAAMC;IACtC,OAAO;QACL,MAAM,IAAII,MAAM,CAAC,gBAAgB,EAAEJ,QAAQC,GAAG,EAAE;IAClD;IAEAX,WACES,MACAX,kBACEK,cACAO,QAAQC,GAAG,KAAK,QAAQP,wBAAwBC,sBAChD,iBAEF,CAACU;QACCb,kCACEa,QACA,SACA,GAAGL,QAAQM,cAAc,CAAC,MAAM,CAAC;QAEnC,OAAOD;IACT;AAEJ,EAAE;AAEF;;CAEC,GACD,MAAMH,6BAA6B,OACjCH,MACAC;IAEA,MAAMO,sBAAsB,CAACC;QAC3BrB,cACEY,MACAX,kBACE,YAAYqB,OAAO,EACnB,SACA,OACA,QACA,OACAD,OAEFpB,kBACEK,cACAC,uBACA,OACA,QACA,QAEF,CAAC,GACD;YACEgB,mBAAmBrB,kBAAkBsB,YAAY;QACnD;IAEJ;IAEA,qDAAqD;IACrDJ,oBAAoBP,QAAQY,aAAa;IACzCL,oBAAoB;IACpB,IAAIP,QAAQa,OAAO,CAACC,IAAI,KAAK,QAAQ;QACnCP,oBAAoB;IACtB;IAEA,sCAAsC;IACtCpB,cACEY,MACAX,kBACE,YAAYqB,OAAO,EACnB,SACA,OACA,OACA,QACAT,QAAQY,aAAa,GAEvBxB,kBACEK,cACAC,uBACA,OACA,OACA,SAEFM,SACA;QACEU,mBAAmBrB,kBAAkBsB,YAAY;IACnD;IAGF,oCAAoC;IACpC,MAAMpB,cACJQ,MACAX,kBACEK,cACAC,uBACA,OACA,OACA,QACA,aAEF,CAAC,EAAE,EAAEM,QAAQe,gBAAgB,CAAC,GAAG,CAAC;IAEpC,MAAMxB,cACJQ,MACAX,kBACEK,cACAC,uBACA,OACA,OACA,aAEF;AAEJ;AAEA;;CAEC,GACD,MAAMS,gCAAgC,CACpCJ,MACAC;IAEA,iCAAiC;IACjCb,cACEY,MACAX,kBACE,YAAYqB,OAAO,EACnB,SACA,aACA,QACA,OACAT,QAAQY,aAAa,GAEvBxB,kBAAkBK,cAAcE,sBAAsB,OAAO,QAAQ,QACrE;QAAEqB,cAAcpB,YAAYqB,KAAK;QAAE,GAAGpB,2BAA2B;IAAC,GAClE;QACEa,mBAAmBrB,kBAAkBsB,YAAY;IACnD;IAGF,yCAAyC;IACzCxB,cACEY,MACAX,kBACE,YAAYqB,OAAO,EACnB,SACA,aACA,OACA,QACAT,QAAQY,aAAa,GAEvBxB,kBAAkBK,cAAcE,sBAAsB,OAAO,OAAO,SACpE;QAAE,GAAGK,OAAO;QAAE,GAAGH,2BAA2B;IAAC,GAC7C;QACEa,mBAAmBrB,kBAAkBsB,YAAY;IACnD;AAEJ"}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
HttpApiIntegration,
|
|
6
6
|
OperationDetails,
|
|
7
7
|
} from './utils.js';
|
|
8
|
-
import { CfnOutput } from 'aws-cdk-lib';
|
|
8
|
+
import { CfnOutput, Stack } from 'aws-cdk-lib';
|
|
9
9
|
import {
|
|
10
10
|
HttpApi as _HttpApi,
|
|
11
11
|
HttpApiProps as _HttpApiProps,
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
ThrottleSettings,
|
|
16
16
|
} from 'aws-cdk-lib/aws-apigatewayv2';
|
|
17
17
|
import { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
18
|
+
import { Key } from 'aws-cdk-lib/aws-kms';
|
|
19
|
+
import { ServicePrincipal } from 'aws-cdk-lib/aws-iam';
|
|
18
20
|
import { suppressRules } from '../checkov.js';
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -91,12 +93,18 @@ export class HttpApi<
|
|
|
91
93
|
...props,
|
|
92
94
|
});
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
// Customer-managed key for access log encryption at rest
|
|
97
|
+
const logsKey = new Key(this, 'AccessLogsKey', {
|
|
98
|
+
enableKeyRotation: true,
|
|
99
|
+
});
|
|
100
|
+
const stack = Stack.of(this);
|
|
101
|
+
logsKey.grantEncryptDecrypt(
|
|
102
|
+
new ServicePrincipal(`logs.${stack.region}.amazonaws.com`),
|
|
99
103
|
);
|
|
104
|
+
|
|
105
|
+
const accessLogGroup = new LogGroup(this, 'AccessLogs', {
|
|
106
|
+
encryptionKey: logsKey,
|
|
107
|
+
});
|
|
100
108
|
suppressRules(
|
|
101
109
|
accessLogGroup,
|
|
102
110
|
['CKV_AWS_66', 'CKV_AWS_338'],
|
package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configures the account-level API Gateway CloudWatch Logs role required for
|
|
3
|
+
* REST API access logging. The setting is a singleton per region per account,
|
|
4
|
+
* so this handler only writes when no live role is already configured (the
|
|
5
|
+
* first stack to deploy wins, others defer) and never resets it on delete.
|
|
6
|
+
*/
|
|
7
|
+
const {
|
|
8
|
+
APIGatewayClient,
|
|
9
|
+
GetAccountCommand,
|
|
10
|
+
UpdateAccountCommand,
|
|
11
|
+
} = require('@aws-sdk/client-api-gateway');
|
|
12
|
+
const { IAMClient, GetRoleCommand } = require('@aws-sdk/client-iam');
|
|
13
|
+
|
|
14
|
+
const apigw = new APIGatewayClient();
|
|
15
|
+
const iam = new IAMClient();
|
|
16
|
+
|
|
17
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
18
|
+
|
|
19
|
+
const hasLiveRole = async () => {
|
|
20
|
+
const { cloudwatchRoleArn } = await apigw.send(new GetAccountCommand({}));
|
|
21
|
+
if (!cloudwatchRoleArn) return false;
|
|
22
|
+
try {
|
|
23
|
+
await iam.send(
|
|
24
|
+
new GetRoleCommand({ RoleName: cloudwatchRoleArn.split('/').pop() }),
|
|
25
|
+
);
|
|
26
|
+
return true;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
if (e.name === 'NoSuchEntityException') return false;
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const RETRYABLE = ['BadRequestException', 'TooManyRequestsException'];
|
|
34
|
+
|
|
35
|
+
const setRole = async (value) => {
|
|
36
|
+
const command = new UpdateAccountCommand({
|
|
37
|
+
patchOperations: [{ op: 'replace', path: '/cloudwatchRoleArn', value }],
|
|
38
|
+
});
|
|
39
|
+
// Retry while the freshly created role propagates through IAM, and on throttling
|
|
40
|
+
for (let attempt = 0; ; attempt++) {
|
|
41
|
+
try {
|
|
42
|
+
return await apigw.send(command);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (RETRYABLE.includes(e.name) && attempt < 11) {
|
|
45
|
+
await sleep(5000);
|
|
46
|
+
} else {
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.handler = async (event) => {
|
|
54
|
+
if (event.RequestType !== 'Delete' && !(await hasLiveRole())) {
|
|
55
|
+
await setRole(event.ResourceProperties.CloudWatchRoleArn);
|
|
56
|
+
}
|
|
57
|
+
return { PhysicalResourceId: 'ApiGatewayAccount' };
|
|
58
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import * as url from 'url';
|
|
3
|
+
import { CustomResource, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib';
|
|
4
|
+
import {
|
|
5
|
+
ManagedPolicy,
|
|
6
|
+
PolicyStatement,
|
|
7
|
+
Role,
|
|
8
|
+
ServicePrincipal,
|
|
9
|
+
} from 'aws-cdk-lib/aws-iam';
|
|
10
|
+
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
11
|
+
import { Provider } from 'aws-cdk-lib/custom-resources';
|
|
12
|
+
|
|
13
|
+
const ApiGatewayAccountKey = '__ApiGatewayAccount__';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Stack-scoped singleton that configures the account-level CloudWatch Logs role
|
|
17
|
+
* used by API Gateway REST APIs for access logging.
|
|
18
|
+
*
|
|
19
|
+
* `AWS::ApiGateway::Account` is a singleton per region per account, so it is
|
|
20
|
+
* managed via an idempotent custom resource: the role is set only when none is
|
|
21
|
+
* already configured, and is never reset on delete. This keeps logging working
|
|
22
|
+
* across multiple stacks sharing an account without one clobbering another.
|
|
23
|
+
*/
|
|
24
|
+
export class ApiGatewayAccount extends Construct {
|
|
25
|
+
static ensure(scope: Construct): ApiGatewayAccount {
|
|
26
|
+
const stack = Stack.of(scope);
|
|
27
|
+
return (
|
|
28
|
+
(stack.node.tryFindChild(ApiGatewayAccountKey) as ApiGatewayAccount) ??
|
|
29
|
+
new ApiGatewayAccount(stack, ApiGatewayAccountKey)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public readonly resource: CustomResource;
|
|
34
|
+
|
|
35
|
+
private constructor(scope: Construct, id: string) {
|
|
36
|
+
super(scope, id);
|
|
37
|
+
|
|
38
|
+
const cloudWatchRole = new Role(this, 'CloudWatchRole', {
|
|
39
|
+
assumedBy: new ServicePrincipal('apigateway.amazonaws.com'),
|
|
40
|
+
managedPolicies: [
|
|
41
|
+
ManagedPolicy.fromAwsManagedPolicyName(
|
|
42
|
+
'service-role/AmazonAPIGatewayPushToCloudWatchLogs',
|
|
43
|
+
),
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
cloudWatchRole.applyRemovalPolicy(RemovalPolicy.RETAIN);
|
|
47
|
+
|
|
48
|
+
const onEvent = new Function(this, 'OnEvent', {
|
|
49
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
50
|
+
handler: 'index.handler',
|
|
51
|
+
timeout: Duration.minutes(2),
|
|
52
|
+
code: Code.fromAsset(
|
|
53
|
+
url.fileURLToPath(new URL('./api-gateway-account', import.meta.url)),
|
|
54
|
+
),
|
|
55
|
+
});
|
|
56
|
+
const { region } = Stack.of(this);
|
|
57
|
+
onEvent.addToRolePolicy(
|
|
58
|
+
new PolicyStatement({
|
|
59
|
+
actions: ['apigateway:GET', 'apigateway:PATCH'],
|
|
60
|
+
resources: [`arn:aws:apigateway:${region}::/account`],
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
onEvent.addToRolePolicy(
|
|
64
|
+
new PolicyStatement({
|
|
65
|
+
actions: ['iam:PassRole'],
|
|
66
|
+
resources: [cloudWatchRole.roleArn],
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
// Read-only; inspects whichever role the account currently references
|
|
70
|
+
onEvent.addToRolePolicy(
|
|
71
|
+
new PolicyStatement({ actions: ['iam:GetRole'], resources: ['*'] }),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
this.resource = new CustomResource(this, 'Resource', {
|
|
75
|
+
serviceToken: new Provider(this, 'Provider', { onEventHandler: onEvent })
|
|
76
|
+
.serviceToken,
|
|
77
|
+
resourceType: 'Custom::ApiGatewayAccount',
|
|
78
|
+
properties: { CloudWatchRoleArn: cloudWatchRole.roleArn },
|
|
79
|
+
});
|
|
80
|
+
this.resource.node.addDependency(cloudWatchRole);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Construct, IConstruct } from 'constructs';
|
|
2
2
|
import {
|
|
3
|
+
AccessLogFormat,
|
|
3
4
|
Cors,
|
|
5
|
+
LogGroupLogDestination,
|
|
4
6
|
Resource,
|
|
5
7
|
RestApi as _RestApi,
|
|
6
8
|
RestApiProps as _RestApiProps,
|
|
@@ -8,14 +10,17 @@ import {
|
|
|
8
10
|
Stage,
|
|
9
11
|
ThrottleSettings,
|
|
10
12
|
} from 'aws-cdk-lib/aws-apigateway';
|
|
11
|
-
import { IAspect,
|
|
13
|
+
import { IAspect, Stack } from 'aws-cdk-lib';
|
|
12
14
|
import {
|
|
13
15
|
CfnLoggingConfiguration,
|
|
14
16
|
CfnWebACL,
|
|
15
17
|
CfnWebACLAssociation,
|
|
16
18
|
} from 'aws-cdk-lib/aws-wafv2';
|
|
17
19
|
import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
|
|
20
|
+
import { Key } from 'aws-cdk-lib/aws-kms';
|
|
21
|
+
import { ServicePrincipal } from 'aws-cdk-lib/aws-iam';
|
|
18
22
|
import { RuntimeConfig } from '../runtime-config.js';
|
|
23
|
+
import { ApiGatewayAccount } from './api-gateway-account.js';
|
|
19
24
|
import {
|
|
20
25
|
ApiIntegrations,
|
|
21
26
|
OperationDetails,
|
|
@@ -100,10 +105,28 @@ export class RestApi<
|
|
|
100
105
|
super(scope, id);
|
|
101
106
|
this.integrations = integrations;
|
|
102
107
|
|
|
108
|
+
// Account-level CloudWatch role required for REST API access logging
|
|
109
|
+
const account = ApiGatewayAccount.ensure(this);
|
|
110
|
+
|
|
111
|
+
// KMS key for encrypting logs at rest, usable by CloudWatch Logs
|
|
112
|
+
const logsKey = new Key(this, 'LogsKey', {
|
|
113
|
+
enableKeyRotation: true,
|
|
114
|
+
});
|
|
115
|
+
logsKey.grantEncryptDecrypt(
|
|
116
|
+
new ServicePrincipal(`logs.${Stack.of(this).region}.amazonaws.com`),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const accessLogs = new LogGroup(this, 'AccessLogs', {
|
|
120
|
+
retention: RetentionDays.ONE_YEAR,
|
|
121
|
+
encryptionKey: logsKey,
|
|
122
|
+
});
|
|
123
|
+
|
|
103
124
|
// Create the API Gateway REST API
|
|
104
125
|
this.api = new _RestApi(this, 'Api', {
|
|
105
126
|
...props,
|
|
106
127
|
deployOptions: {
|
|
128
|
+
accessLogDestination: new LogGroupLogDestination(accessLogs),
|
|
129
|
+
accessLogFormat: AccessLogFormat.jsonWithStandardFields(),
|
|
107
130
|
...props.deployOptions,
|
|
108
131
|
methodOptions: {
|
|
109
132
|
...props.deployOptions?.methodOptions,
|
|
@@ -116,6 +139,8 @@ export class RestApi<
|
|
|
116
139
|
},
|
|
117
140
|
},
|
|
118
141
|
});
|
|
142
|
+
// Ensure the account-level role is configured before the stage is created
|
|
143
|
+
this.api.deploymentStage.node.addDependency(account.resource);
|
|
119
144
|
|
|
120
145
|
if (enableWaf) {
|
|
121
146
|
this.webAcl = new CfnWebACL(this, 'WebAcl', {
|
|
@@ -182,14 +207,9 @@ export class RestApi<
|
|
|
182
207
|
// `aws-waf-logs-` to satisfy the WAFv2 logging destination requirement.
|
|
183
208
|
const wafLogGroup = new LogGroup(this, 'WebAclLogs', {
|
|
184
209
|
logGroupName: `aws-waf-logs-${apiName}-${this.node.addr.slice(-8)}`,
|
|
185
|
-
retention: RetentionDays.
|
|
186
|
-
|
|
210
|
+
retention: RetentionDays.ONE_YEAR,
|
|
211
|
+
encryptionKey: logsKey,
|
|
187
212
|
});
|
|
188
|
-
suppressRules(
|
|
189
|
-
wafLogGroup,
|
|
190
|
-
['CKV_AWS_158'],
|
|
191
|
-
'Using default CloudWatch log encryption for WAF logs',
|
|
192
|
-
);
|
|
193
213
|
|
|
194
214
|
new CfnLoggingConfiguration(this, 'WebAclLoggingConfig', {
|
|
195
215
|
resourceArn: this.webAcl.attrArn,
|
|
@@ -203,12 +223,6 @@ export class RestApi<
|
|
|
203
223
|
'Caching not required for this use case',
|
|
204
224
|
(c) => c instanceof Stage,
|
|
205
225
|
);
|
|
206
|
-
suppressRules(
|
|
207
|
-
this.api,
|
|
208
|
-
['CKV_AWS_76'],
|
|
209
|
-
'API Gateway access logging disabled due to account-level CloudWatch Logs role ARN requirement',
|
|
210
|
-
(c) => c instanceof Stage,
|
|
211
|
-
);
|
|
212
226
|
|
|
213
227
|
// Resolve the integration for a given operation.
|
|
214
228
|
// If the operation has a dedicated integration, use it; otherwise fall back to $router.
|
|
@@ -4,7 +4,7 @@ terraform {
|
|
|
4
4
|
required_providers {
|
|
5
5
|
aws = {
|
|
6
6
|
source = "hashicorp/aws"
|
|
7
|
-
version = "
|
|
7
|
+
version = "<%- awsProviderVersion %>"
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -74,12 +74,6 @@ variable "cors_expose_headers" {
|
|
|
74
74
|
default = []
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
variable "cors_max_age" {
|
|
78
|
-
description = "Maximum age for CORS preflight requests in seconds"
|
|
79
|
-
type = number
|
|
80
|
-
default = 0
|
|
81
|
-
}
|
|
82
|
-
|
|
83
77
|
# Tags
|
|
84
78
|
variable "tags" {
|
|
85
79
|
description = "Tags to apply to all resources"
|
|
@@ -130,7 +124,6 @@ module "http_api" {
|
|
|
130
124
|
cors_allow_methods = var.cors_allow_methods
|
|
131
125
|
cors_allow_origins = var.cors_allow_origins
|
|
132
126
|
cors_expose_headers = var.cors_expose_headers
|
|
133
|
-
cors_max_age = var.cors_max_age
|
|
134
127
|
|
|
135
128
|
# Tags
|
|
136
129
|
tags = var.tags
|
|
@@ -4,7 +4,7 @@ terraform {
|
|
|
4
4
|
required_providers {
|
|
5
5
|
aws = {
|
|
6
6
|
source = "hashicorp/aws"
|
|
7
|
-
version = "
|
|
7
|
+
version = "<%- awsProviderVersion %>"
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -105,6 +105,11 @@ resource "aws_s3_object" "lambda_zip" {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
# Use the core REST API module
|
|
108
|
+
# Account-level CloudWatch role required for REST API access logging
|
|
109
|
+
module "account" {
|
|
110
|
+
source = "../../../core/api/api-gateway-account"
|
|
111
|
+
}
|
|
112
|
+
|
|
108
113
|
module "rest_api" {
|
|
109
114
|
source = "../../../core/api/rest-api"
|
|
110
115
|
|
|
@@ -509,11 +514,63 @@ resource "aws_api_gateway_deployment" "api_deployment" {
|
|
|
509
514
|
]
|
|
510
515
|
}
|
|
511
516
|
|
|
517
|
+
# KMS key for encrypting access logs at rest
|
|
518
|
+
resource "aws_kms_key" "access_logs" {
|
|
519
|
+
description = "<%- apiNameClassName %> API access log encryption"
|
|
520
|
+
deletion_window_in_days = 7
|
|
521
|
+
enable_key_rotation = true
|
|
522
|
+
|
|
523
|
+
policy = jsonencode({
|
|
524
|
+
Version = "2012-10-17"
|
|
525
|
+
Statement = [
|
|
526
|
+
{
|
|
527
|
+
Sid = "Enable IAM User Permissions"
|
|
528
|
+
Effect = "Allow"
|
|
529
|
+
Principal = { AWS = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root" }
|
|
530
|
+
Action = "kms:*"
|
|
531
|
+
Resource = "*"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
Sid = "Allow CloudWatch Logs"
|
|
535
|
+
Effect = "Allow"
|
|
536
|
+
Principal = { Service = "logs.${data.aws_region.current.region}.amazonaws.com" }
|
|
537
|
+
Action = [
|
|
538
|
+
"kms:Encrypt",
|
|
539
|
+
"kms:Decrypt",
|
|
540
|
+
"kms:ReEncrypt*",
|
|
541
|
+
"kms:GenerateDataKey*",
|
|
542
|
+
"kms:DescribeKey"
|
|
543
|
+
]
|
|
544
|
+
Resource = "*"
|
|
545
|
+
Condition = {
|
|
546
|
+
ArnEquals = {
|
|
547
|
+
"kms:EncryptionContext:aws:logs:arn" = "arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:log-group:/aws/apigateway/<%- apiNameKebabCase %>-${random_string.suffix.result}/access"
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
]
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
tags = var.tags
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
resource "aws_kms_alias" "access_logs" {
|
|
558
|
+
name = "alias/<%- apiNameKebabCase %>-${random_string.suffix.result}-access-logs"
|
|
559
|
+
target_key_id = aws_kms_key.access_logs.key_id
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
# Access logs for the API Gateway stage
|
|
563
|
+
resource "aws_cloudwatch_log_group" "access_logs" {
|
|
564
|
+
name = "/aws/apigateway/<%- apiNameKebabCase %>-${random_string.suffix.result}/access"
|
|
565
|
+
retention_in_days = 365
|
|
566
|
+
kms_key_id = aws_kms_key.access_logs.arn
|
|
567
|
+
tags = var.tags
|
|
568
|
+
}
|
|
569
|
+
|
|
512
570
|
# API Gateway stage
|
|
513
571
|
resource "aws_api_gateway_stage" "api_stage" {
|
|
514
572
|
#checkov:skip=CKV_AWS_120:API Gateway caching not required for this use case
|
|
515
|
-
#checkov:skip=
|
|
516
|
-
#checkov:skip=CKV2_AWS_4:API Gateway logging level not applicable as access logging is disabled
|
|
573
|
+
#checkov:skip=CKV2_AWS_4:Access logging is enabled below; verbose execution logging is intentionally not enabled
|
|
517
574
|
#checkov:skip=CKV2_AWS_51:Client certificate authentication not required for this use case
|
|
518
575
|
#checkov:skip=CKV2_AWS_77:WAFv2 Web ACL is attached via aws_wafv2_web_acl_association when var.enable_waf is true (default) and includes AWSManagedRulesKnownBadInputsRuleSet for Log4j protection; Checkov does not track the association across modules
|
|
519
576
|
deployment_id = aws_api_gateway_deployment.api_deployment.id
|
|
@@ -521,9 +578,39 @@ resource "aws_api_gateway_stage" "api_stage" {
|
|
|
521
578
|
stage_name = "prod"
|
|
522
579
|
xray_tracing_enabled = true
|
|
523
580
|
|
|
581
|
+
access_log_settings {
|
|
582
|
+
destination_arn = aws_cloudwatch_log_group.access_logs.arn
|
|
583
|
+
format = jsonencode({
|
|
584
|
+
requestId = "$context.requestId"
|
|
585
|
+
ip = "$context.identity.sourceIp"
|
|
586
|
+
caller = "$context.identity.caller"
|
|
587
|
+
user = "$context.identity.user"
|
|
588
|
+
requestTime = "$context.requestTime"
|
|
589
|
+
httpMethod = "$context.httpMethod"
|
|
590
|
+
resourcePath = "$context.resourcePath"
|
|
591
|
+
status = "$context.status"
|
|
592
|
+
protocol = "$context.protocol"
|
|
593
|
+
responseLength = "$context.responseLength"
|
|
594
|
+
})
|
|
595
|
+
}
|
|
596
|
+
|
|
524
597
|
tags = var.tags
|
|
525
598
|
|
|
526
|
-
|
|
599
|
+
# Ensure the account-level role is configured before the stage is created
|
|
600
|
+
depends_on = [aws_api_gateway_deployment.api_deployment, module.account]
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
# Default throttling applied to all resource paths and methods
|
|
604
|
+
resource "aws_api_gateway_method_settings" "throttling" {
|
|
605
|
+
#checkov:skip=CKV_AWS_225:API Gateway caching not required for this use case
|
|
606
|
+
rest_api_id = module.rest_api.api_id
|
|
607
|
+
stage_name = aws_api_gateway_stage.api_stage.stage_name
|
|
608
|
+
method_path = "*/*"
|
|
609
|
+
|
|
610
|
+
settings {
|
|
611
|
+
throttling_rate_limit = 10000
|
|
612
|
+
throttling_burst_limit = 5000
|
|
613
|
+
}
|
|
527
614
|
}
|
|
528
615
|
|
|
529
616
|
# API Gateway Resource Policy
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Account-level CloudWatch Logs role used by API Gateway REST APIs for access
|
|
2
|
+
# logging. The setting is a singleton per region per account, so it is managed
|
|
3
|
+
# idempotently: the role is set only when none is already configured (the first
|
|
4
|
+
# deployment wins, others defer) and is never reset on destroy. This keeps
|
|
5
|
+
# logging working across multiple deployments sharing an account.
|
|
6
|
+
|
|
7
|
+
terraform {
|
|
8
|
+
required_version = ">= 1.0"
|
|
9
|
+
|
|
10
|
+
required_providers {
|
|
11
|
+
aws = {
|
|
12
|
+
source = "hashicorp/aws"
|
|
13
|
+
version = "<%- awsProviderVersion %>"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
data "aws_region" "current" {}
|
|
19
|
+
|
|
20
|
+
resource "aws_iam_role" "cloudwatch" {
|
|
21
|
+
name_prefix = "apigw-cloudwatch-"
|
|
22
|
+
|
|
23
|
+
assume_role_policy = jsonencode({
|
|
24
|
+
Version = "2012-10-17"
|
|
25
|
+
Statement = [{
|
|
26
|
+
Effect = "Allow"
|
|
27
|
+
Principal = { Service = "apigateway.amazonaws.com" }
|
|
28
|
+
Action = "sts:AssumeRole"
|
|
29
|
+
}]
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
resource "aws_iam_role_policy_attachment" "cloudwatch" {
|
|
34
|
+
role = aws_iam_role.cloudwatch.name
|
|
35
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Configures the account role on create/update only; destroying this resource is
|
|
39
|
+
# a no-op, so teardown never disables logging for other REST APIs in the region.
|
|
40
|
+
resource "terraform_data" "account" {
|
|
41
|
+
triggers_replace = [aws_iam_role.cloudwatch.arn]
|
|
42
|
+
|
|
43
|
+
provisioner "local-exec" {
|
|
44
|
+
command = "uv run --with boto3<%= boto3Version %> python -c \"$SCRIPT\""
|
|
45
|
+
environment = {
|
|
46
|
+
ROLE_ARN = aws_iam_role.cloudwatch.arn
|
|
47
|
+
REGION = data.aws_region.current.region
|
|
48
|
+
SCRIPT = <<-PY
|
|
49
|
+
import os, time, boto3
|
|
50
|
+
from botocore.exceptions import ClientError
|
|
51
|
+
apigw = boto3.client("apigateway", region_name=os.environ["REGION"])
|
|
52
|
+
|
|
53
|
+
def has_live_role():
|
|
54
|
+
arn = apigw.get_account().get("cloudwatchRoleArn")
|
|
55
|
+
if not arn:
|
|
56
|
+
return False
|
|
57
|
+
try:
|
|
58
|
+
boto3.client("iam").get_role(RoleName=arn.split("/")[-1])
|
|
59
|
+
return True
|
|
60
|
+
except ClientError as e:
|
|
61
|
+
if e.response["Error"]["Code"] == "NoSuchEntity":
|
|
62
|
+
return False
|
|
63
|
+
raise
|
|
64
|
+
|
|
65
|
+
if not has_live_role():
|
|
66
|
+
op = {"op": "replace", "path": "/cloudwatchRoleArn", "value": os.environ["ROLE_ARN"]}
|
|
67
|
+
# Retry while the freshly created role propagates through IAM, and on throttling
|
|
68
|
+
retryable = ("BadRequestException", "TooManyRequestsException")
|
|
69
|
+
for attempt in range(12):
|
|
70
|
+
try:
|
|
71
|
+
apigw.update_account(patchOperations=[op])
|
|
72
|
+
break
|
|
73
|
+
except ClientError as e:
|
|
74
|
+
if e.response["Error"]["Code"] in retryable and attempt < 11:
|
|
75
|
+
time.sleep(5)
|
|
76
|
+
else:
|
|
77
|
+
raise
|
|
78
|
+
PY
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
depends_on = [aws_iam_role_policy_attachment.cloudwatch]
|
|
83
|
+
}
|
package/src/utils/api-constructs/files/terraform/core/api/rest/rest-api/rest-api.tf.template
CHANGED
|
@@ -7,11 +7,11 @@ terraform {
|
|
|
7
7
|
required_providers {
|
|
8
8
|
aws = {
|
|
9
9
|
source = "hashicorp/aws"
|
|
10
|
-
version = "
|
|
10
|
+
version = "<%- awsProviderVersion %>"
|
|
11
11
|
}
|
|
12
12
|
random = {
|
|
13
13
|
source = "hashicorp/random"
|
|
14
|
-
version = "
|
|
14
|
+
version = "<%- randomProviderVersion %>"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -81,8 +81,6 @@ data "aws_caller_identity" "current" {}
|
|
|
81
81
|
|
|
82
82
|
# Resources
|
|
83
83
|
|
|
84
|
-
# Note: CloudWatch logging removed due to account-level CloudWatch Logs role ARN requirement
|
|
85
|
-
|
|
86
84
|
# REST API Gateway
|
|
87
85
|
resource "aws_api_gateway_rest_api" "rest_api" {
|
|
88
86
|
name = var.api_name
|
|
@@ -99,10 +97,8 @@ resource "aws_api_gateway_rest_api" "rest_api" {
|
|
|
99
97
|
tags = var.tags
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
# Note: Deployment and
|
|
103
|
-
# after all methods and integrations are defined
|
|
104
|
-
|
|
105
|
-
# Note: CloudWatch Log Group removed due to account-level CloudWatch Logs role ARN requirement
|
|
100
|
+
# Note: Deployment, stage and access logging are created in the consuming module
|
|
101
|
+
# (e.g., foo-api.tf) after all methods and integrations are defined
|
|
106
102
|
|
|
107
103
|
# Gateway Response for CORS (4XX errors)
|
|
108
104
|
resource "aws_api_gateway_gateway_response" "cors_4xx" {
|
|
@@ -260,6 +256,4 @@ output "waf_web_acl_arn" {
|
|
|
260
256
|
value = var.enable_waf ? aws_wafv2_web_acl.api_waf[0].arn : null
|
|
261
257
|
}
|
|
262
258
|
|
|
263
|
-
# Note: Stage and
|
|
264
|
-
|
|
265
|
-
# Note: CloudWatch log group outputs removed due to account-level CloudWatch Logs role ARN requirement
|
|
259
|
+
# Note: Stage, deployment and access log outputs are provided by the consuming module
|