@aws/nx-plugin 1.0.0-rc.33 → 1.0.0-rc.35
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 +28 -41
- package/generators.json +27 -0
- package/package.json +6 -6
- package/src/connection/generator.js +12 -1
- package/src/connection/generator.js.map +1 -1
- package/src/connection/supported-connections.d.ts +10 -1
- package/src/connection/supported-connections.js +13 -0
- package/src/connection/supported-connections.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +12 -12
- package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +74 -10
- package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +22 -4
- package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +53 -8
- package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +32 -4
- package/src/open-api/ts-client/__snapshots__/generator.fast-api-gaps.spec.ts.snap +736 -0
- package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +86 -11
- package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +21 -3
- package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +2 -2
- package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +6 -6
- package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +2 -2
- package/src/open-api/ts-client/__snapshots__/generator.spec-compliance.spec.ts.snap +1883 -0
- package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +4 -4
- package/src/open-api/ts-client/files/client.gen.ts.template +195 -12
- package/src/open-api/ts-client/files/types.gen.ts.template +2 -0
- package/src/open-api/ts-client/generator.js +22 -1
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/utils/codegen-data/languages.js +6 -0
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data/types.d.ts +16 -1
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.js +71 -0
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +53 -8
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.js +48 -15
- package/src/open-api/utils/parser.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +4 -2
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +1 -1
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +186 -18
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +2038 -0
- package/src/py/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +104 -0
- package/src/py/rdb/agent-connection/generator.d.ts +10 -0
- package/src/py/rdb/agent-connection/generator.js +46 -0
- package/src/py/rdb/agent-connection/generator.js.map +1 -0
- package/src/py/rdb/agent-connection/schema.d.js +8 -0
- package/src/py/rdb/agent-connection/schema.d.js.map +1 -0
- package/src/py/rdb/agent-connection/schema.d.ts +15 -0
- package/src/py/rdb/agent-connection/schema.json +27 -0
- package/src/py/rdb/fast-api-connection/__snapshots__/generator.spec.ts.snap +44 -0
- package/src/py/rdb/fast-api-connection/files/__apiModuleName__/dependencies/__rdbNameSnake__.py.template +14 -0
- package/src/py/rdb/fast-api-connection/generator.d.ts +10 -0
- package/src/py/rdb/fast-api-connection/generator.js +54 -0
- package/src/py/rdb/fast-api-connection/generator.js.map +1 -0
- package/src/py/rdb/fast-api-connection/schema.d.js +8 -0
- package/src/py/rdb/fast-api-connection/schema.d.js.map +1 -0
- package/src/py/rdb/fast-api-connection/schema.d.ts +13 -0
- package/src/py/rdb/fast-api-connection/schema.json +23 -0
- package/src/py/rdb/files/Dockerfile.create-db-user.template +10 -0
- package/src/py/rdb/files/Dockerfile.migration.template +10 -0
- package/src/py/rdb/files/__name__/__init__.py.template +3 -0
- package/src/py/rdb/files/__name__/connection.py.template +55 -0
- package/src/py/rdb/files/__name__/create_db_user_handler.py.template +97 -0
- package/src/py/rdb/files/__name__/migration_handler.py.template +36 -0
- package/src/py/rdb/files/__name__/models/__init__.py.template +3 -0
- package/src/py/rdb/files/__name__/models/example.py.template +8 -0
- package/src/py/rdb/files/__name__/utils.py.template +104 -0
- package/src/py/rdb/files/alembic.ini.template +38 -0
- package/src/py/rdb/files/config.json.template +14 -0
- package/src/py/rdb/files/migrations/env.py.template +80 -0
- package/src/py/rdb/files/migrations/script.py.mako.template +28 -0
- package/src/py/rdb/generator.d.ts +6 -0
- package/src/py/rdb/generator.js +263 -0
- package/src/py/rdb/generator.js.map +1 -0
- package/src/py/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +101 -0
- package/src/py/rdb/mcp-server-connection/generator.d.ts +10 -0
- package/src/py/rdb/mcp-server-connection/generator.js +46 -0
- package/src/py/rdb/mcp-server-connection/generator.js.map +1 -0
- package/src/py/rdb/mcp-server-connection/schema.d.js +8 -0
- package/src/py/rdb/mcp-server-connection/schema.d.js.map +1 -0
- package/src/py/rdb/mcp-server-connection/schema.d.ts +15 -0
- package/src/py/rdb/mcp-server-connection/schema.json +27 -0
- package/src/py/rdb/schema.d.js +6 -0
- package/src/py/rdb/schema.d.js.map +1 -0
- package/src/py/rdb/schema.d.ts +16 -0
- package/src/py/rdb/schema.json +77 -0
- package/src/py/rdb/utils.d.ts +6 -0
- package/src/py/rdb/utils.js +16 -0
- package/src/py/rdb/utils.js.map +1 -0
- package/src/sdk/py.d.ts +2 -0
- package/src/sdk/py.js +1 -0
- package/src/sdk/py.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +124 -12
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +186 -18
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +145 -173
- package/src/ts/rdb/generator.js +4 -3
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/schema.json +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +16 -16
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +31 -3
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +31 -3
- package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +58 -14
- package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +68 -78
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +88 -8
- package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +5 -32
- package/src/utils/rdb-constructs/rdb-constructs.d.ts +11 -1
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs.js +9 -21
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-rdb-scripts.js +5 -1
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/versions.d.ts +34 -30
- package/src/utils/versions.js +34 -30
- package/src/utils/versions.js.map +1 -1
- package/src/utils/files/terraform/scripts/reset-runtime-config.ts.template +0 -25
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`py#rdb mcp-server-connection generator > should add RDS CA bundle to Dockerfile 1`] = `
|
|
4
|
+
"FROM public.ecr.aws/docker/library/python:3.14-slim
|
|
5
|
+
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
COPY . /app
|
|
9
|
+
|
|
10
|
+
ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /usr/local/share/ca-certificates/rds-global-bundle.crt
|
|
11
|
+
RUN update-ca-certificates
|
|
12
|
+
|
|
13
|
+
EXPOSE 8000
|
|
14
|
+
|
|
15
|
+
ENV PYTHONPATH=/app
|
|
16
|
+
|
|
17
|
+
CMD ["python", "-m", "uvicorn", "proj_my_mcp_server.mcp_server.http:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
18
|
+
"
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`py#rdb mcp-server-connection generator > should add RDS CA bundle to sourceComponent Dockerfile 1`] = `
|
|
22
|
+
"FROM public.ecr.aws/docker/library/python:3.14-slim
|
|
23
|
+
|
|
24
|
+
WORKDIR /app
|
|
25
|
+
|
|
26
|
+
COPY . /app
|
|
27
|
+
|
|
28
|
+
ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /usr/local/share/ca-certificates/rds-global-bundle.crt
|
|
29
|
+
RUN update-ca-certificates
|
|
30
|
+
|
|
31
|
+
EXPOSE 8000
|
|
32
|
+
|
|
33
|
+
ENV PYTHONPATH=/app
|
|
34
|
+
|
|
35
|
+
CMD ["python", "-m", "uvicorn", "proj_my_mcp_server.custom_mcp_server.http:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
36
|
+
"
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`py#rdb mcp-server-connection generator > should add rdb dev dependency to mcp-server dev 1`] = `
|
|
40
|
+
{
|
|
41
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
42
|
+
"name": "my-mcp-server",
|
|
43
|
+
"root": "packages/my-mcp-server",
|
|
44
|
+
"sourceRoot": "packages/my-mcp-server/src/proj_my_mcp_server",
|
|
45
|
+
"targets": {
|
|
46
|
+
"mcp-server-dev": {
|
|
47
|
+
"continuous": true,
|
|
48
|
+
"dependsOn": [
|
|
49
|
+
{
|
|
50
|
+
"projects": [
|
|
51
|
+
"db",
|
|
52
|
+
],
|
|
53
|
+
"target": "dev",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
"executor": "nx:run-commands",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
exports[`py#rdb mcp-server-connection generator > should be idempotent for Dockerfile 1`] = `
|
|
63
|
+
"FROM public.ecr.aws/docker/library/python:3.14-slim
|
|
64
|
+
|
|
65
|
+
WORKDIR /app
|
|
66
|
+
|
|
67
|
+
COPY . /app
|
|
68
|
+
|
|
69
|
+
ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /usr/local/share/ca-certificates/rds-global-bundle.crt
|
|
70
|
+
RUN update-ca-certificates
|
|
71
|
+
|
|
72
|
+
EXPOSE 8000
|
|
73
|
+
|
|
74
|
+
ENV PYTHONPATH=/app
|
|
75
|
+
|
|
76
|
+
CMD ["python", "-m", "uvicorn", "proj_my_mcp_server.mcp_server.http:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
77
|
+
"
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
exports[`py#rdb mcp-server-connection generator > should use sourceComponent name when provided 1`] = `
|
|
81
|
+
{
|
|
82
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
83
|
+
"name": "my-mcp-server",
|
|
84
|
+
"root": "packages/my-mcp-server",
|
|
85
|
+
"sourceRoot": "packages/my-mcp-server/src/proj_my_mcp_server",
|
|
86
|
+
"targets": {
|
|
87
|
+
"custom-mcp-server-dev": {
|
|
88
|
+
"continuous": true,
|
|
89
|
+
"dependsOn": [
|
|
90
|
+
{
|
|
91
|
+
"projects": [
|
|
92
|
+
"db",
|
|
93
|
+
],
|
|
94
|
+
"target": "dev",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
"executor": "nx:run-commands",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../../utils/nx';
|
|
7
|
+
import type { PyRdbMcpServerConnectionGeneratorSchema } from './schema';
|
|
8
|
+
export declare const PY_RDB_MCP_SERVER_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
export declare const pyRdbMcpServerConnectionGenerator: (tree: Tree, options: PyRdbMcpServerConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
|
+
export default pyRdbMcpServerConnectionGenerator;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { joinPathFragments, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
+
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
6
|
+
import { installDependencies } from "../../../utils/install.js";
|
|
7
|
+
import { addGeneratorMetricsIfApplicable } from "../../../utils/metrics.js";
|
|
8
|
+
import { toSnakeCase } from "../../../utils/names.js";
|
|
9
|
+
import { addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
10
|
+
import { addWorkspaceDependencyToPyProject } from "../../../utils/py.js";
|
|
11
|
+
import { injectRdsCaBundleIntoDockerfile } from "../utils.js";
|
|
12
|
+
export const PY_RDB_MCP_SERVER_CONNECTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
13
|
+
export const pyRdbMcpServerConnectionGenerator = async (tree, options)=>{
|
|
14
|
+
const sourceProject = readProjectConfigurationUnqualified(tree, options.sourceProject);
|
|
15
|
+
const targetProject = readProjectConfigurationUnqualified(tree, options.targetProject);
|
|
16
|
+
addWorkspaceDependencyToPyProject(tree, sourceProject, targetProject);
|
|
17
|
+
const mcpServerName = options.sourceComponent?.name ?? 'mcp-server';
|
|
18
|
+
const devTarget = `${mcpServerName}-dev`;
|
|
19
|
+
const mcpServerSourceDir = options.sourceComponent?.path ? joinPathFragments(sourceProject.root, options.sourceComponent.path) : sourceProject.sourceRoot ? joinPathFragments(sourceProject.sourceRoot, toSnakeCase(mcpServerName)) : undefined;
|
|
20
|
+
const dockerfilePath = mcpServerSourceDir ? joinPathFragments(mcpServerSourceDir, 'Dockerfile') : undefined;
|
|
21
|
+
if (dockerfilePath) {
|
|
22
|
+
injectRdsCaBundleIntoDockerfile(tree, dockerfilePath);
|
|
23
|
+
}
|
|
24
|
+
if (sourceProject.targets?.[devTarget]) {
|
|
25
|
+
addDependencyToTargetIfNotPresent(sourceProject, devTarget, {
|
|
26
|
+
projects: [
|
|
27
|
+
targetProject.name
|
|
28
|
+
],
|
|
29
|
+
target: 'dev'
|
|
30
|
+
});
|
|
31
|
+
updateProjectConfiguration(tree, sourceProject.name, sourceProject);
|
|
32
|
+
}
|
|
33
|
+
await addGeneratorMetricsIfApplicable(tree, [
|
|
34
|
+
PY_RDB_MCP_SERVER_CONNECTION_GENERATOR_INFO
|
|
35
|
+
]);
|
|
36
|
+
await formatFilesInSubtree(tree);
|
|
37
|
+
return ()=>installDependencies(tree, options.preferInstallDependencies, {
|
|
38
|
+
languages: [
|
|
39
|
+
'typescript',
|
|
40
|
+
'python'
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export default pyRdbMcpServerConnectionGenerator;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/rdb/mcp-server-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n joinPathFragments,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { toSnakeCase } from '../../../utils/names';\nimport {\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { addWorkspaceDependencyToPyProject } from '../../../utils/py';\nimport { injectRdsCaBundleIntoDockerfile } from '../utils';\nimport type { PyRdbMcpServerConnectionGeneratorSchema } from './schema';\n\nexport const PY_RDB_MCP_SERVER_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyRdbMcpServerConnectionGenerator = async (\n tree: Tree,\n options: PyRdbMcpServerConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n addWorkspaceDependencyToPyProject(tree, sourceProject, targetProject);\n\n const mcpServerName = options.sourceComponent?.name ?? 'mcp-server';\n const devTarget = `${mcpServerName}-dev`;\n const mcpServerSourceDir = options.sourceComponent?.path\n ? joinPathFragments(sourceProject.root, options.sourceComponent.path)\n : sourceProject.sourceRoot\n ? joinPathFragments(sourceProject.sourceRoot, toSnakeCase(mcpServerName))\n : undefined;\n const dockerfilePath = mcpServerSourceDir\n ? joinPathFragments(mcpServerSourceDir, 'Dockerfile')\n : undefined;\n\n if (dockerfilePath) {\n injectRdsCaBundleIntoDockerfile(tree, dockerfilePath);\n }\n\n if (sourceProject.targets?.[devTarget]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTarget, {\n projects: [targetProject.name],\n target: 'dev',\n });\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n await addGeneratorMetricsIfApplicable(tree, [\n PY_RDB_MCP_SERVER_CONNECTION_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyRdbMcpServerConnectionGenerator;\n"],"names":["joinPathFragments","updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toSnakeCase","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","addWorkspaceDependencyToPyProject","injectRdsCaBundleIntoDockerfile","PY_RDB_MCP_SERVER_CONNECTION_GENERATOR_INFO","filename","pyRdbMcpServerConnectionGenerator","tree","options","sourceProject","targetProject","mcpServerName","sourceComponent","name","devTarget","mcpServerSourceDir","path","root","sourceRoot","undefined","dockerfilePath","targets","projects","target","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SAASC,WAAW,QAAQ,0BAAuB;AACnD,SACEC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SAASC,iCAAiC,QAAQ,uBAAoB;AACtE,SAASC,+BAA+B,QAAQ,cAAW;AAG3D,OAAO,MAAMC,8CACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC,OAAO,MAAMC,oCAAoC,OAC/CC,MACAC;IAEA,MAAMC,gBAAgBR,oCACpBM,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBT,oCACpBM,MACAC,QAAQE,aAAa;IAGvBR,kCAAkCK,MAAME,eAAeC;IAEvD,MAAMC,gBAAgBH,QAAQI,eAAe,EAAEC,QAAQ;IACvD,MAAMC,YAAY,GAAGH,cAAc,IAAI,CAAC;IACxC,MAAMI,qBAAqBP,QAAQI,eAAe,EAAEI,OAChDvB,kBAAkBgB,cAAcQ,IAAI,EAAET,QAAQI,eAAe,CAACI,IAAI,IAClEP,cAAcS,UAAU,GACtBzB,kBAAkBgB,cAAcS,UAAU,EAAEpB,YAAYa,kBACxDQ;IACN,MAAMC,iBAAiBL,qBACnBtB,kBAAkBsB,oBAAoB,gBACtCI;IAEJ,IAAIC,gBAAgB;QAClBjB,gCAAgCI,MAAMa;IACxC;IAEA,IAAIX,cAAcY,OAAO,EAAE,CAACP,UAAU,EAAE;QACtCf,kCAAkCU,eAAeK,WAAW;YAC1DQ,UAAU;gBAACZ,cAAcG,IAAI;aAAC;YAC9BU,QAAQ;QACV;QACA7B,2BAA2Ba,MAAME,cAAcI,IAAI,EAAEJ;IACvD;IAEA,MAAMZ,gCAAgCU,MAAM;QAC1CH;KACD;IACD,MAAMT,qBAAqBY;IAC3B,OAAO,IACLX,oBAAoBW,MAAMC,QAAQgB,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAenB,kCAAkC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/rdb/mcp-server-connection/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { ComponentMetadata } from '../../../utils/nx';\n\n/**\n * TypeScript types for options defined in schema.json\n */\nexport interface PyRdbMcpServerConnectionGeneratorSchema {\n sourceProject: string;\n targetProject: string;\n sourceComponent?: ComponentMetadata;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD;;CAEC,GACD,WAKC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { ComponentMetadata } from '../../../utils/nx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TypeScript types for options defined in schema.json
|
|
9
|
+
*/
|
|
10
|
+
export interface PyRdbMcpServerConnectionGeneratorSchema {
|
|
11
|
+
sourceProject: string;
|
|
12
|
+
targetProject: string;
|
|
13
|
+
sourceComponent?: ComponentMetadata;
|
|
14
|
+
preferInstallDependencies?: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "py#rdb#mcp-server-connection",
|
|
4
|
+
"title": "py#rdb#mcp-server-connection",
|
|
5
|
+
"description": "Connect a py#mcp-server to a py#rdb project",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"sourceProject": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The project containing the py#mcp-server to connect from"
|
|
11
|
+
},
|
|
12
|
+
"targetProject": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The py#rdb project to connect to"
|
|
15
|
+
},
|
|
16
|
+
"sourceComponent": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The MCP server component name"
|
|
19
|
+
},
|
|
20
|
+
"preferInstallDependencies": {
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
23
|
+
"default": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": ["sourceProject", "targetProject"]
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/rdb/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface PyRdbGeneratorSchema {\n name: string;\n directory?: string;\n subDirectory?: string;\n infra: 'aurora' | 'none';\n engine: 'postgres' | 'mysql';\n databaseUser?: string;\n databaseName?: string;\n framework: 'sqlmodel';\n iac?: 'inherit' | 'cdk' | 'terraform';\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,WAWC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export interface PyRdbGeneratorSchema {
|
|
6
|
+
name: string;
|
|
7
|
+
directory?: string;
|
|
8
|
+
subDirectory?: string;
|
|
9
|
+
infra: 'aurora' | 'none';
|
|
10
|
+
engine: 'postgres' | 'mysql';
|
|
11
|
+
databaseUser?: string;
|
|
12
|
+
databaseName?: string;
|
|
13
|
+
framework: 'sqlmodel';
|
|
14
|
+
iac?: 'inherit' | 'cdk' | 'terraform';
|
|
15
|
+
preferInstallDependencies?: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "py#rdb",
|
|
4
|
+
"title": "py#rdb",
|
|
5
|
+
"description": "Create a Python relational database project",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Name of the database project to generate",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-priority": "important",
|
|
16
|
+
"x-prompt": "What name would you like your database project to have? i.e: MyDb"
|
|
17
|
+
},
|
|
18
|
+
"directory": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The directory to store the application in.",
|
|
21
|
+
"default": "packages",
|
|
22
|
+
"x-priority": "important",
|
|
23
|
+
"x-prompt": "Which directory do you want to create the project in?"
|
|
24
|
+
},
|
|
25
|
+
"subDirectory": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "The sub directory the project is placed in. By default this is the project name."
|
|
28
|
+
},
|
|
29
|
+
"infra": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": ["aurora", "none"],
|
|
32
|
+
"default": "aurora",
|
|
33
|
+
"description": "Relational database service to provision.",
|
|
34
|
+
"x-priority": "important",
|
|
35
|
+
"x-prompt": "Which database service would you like to use?"
|
|
36
|
+
},
|
|
37
|
+
"engine": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["postgres", "mysql"],
|
|
40
|
+
"default": "postgres",
|
|
41
|
+
"description": "Database engine to use with the selected service.",
|
|
42
|
+
"x-priority": "important",
|
|
43
|
+
"x-prompt": "Which database engine would you like to use?"
|
|
44
|
+
},
|
|
45
|
+
"databaseUser": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Database admin username. Defaults to 'dbadmin'.",
|
|
48
|
+
"default": "dbadmin"
|
|
49
|
+
},
|
|
50
|
+
"databaseName": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "Initial database name. Defaults to the project name."
|
|
53
|
+
},
|
|
54
|
+
"framework": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"enum": ["sqlmodel"],
|
|
57
|
+
"default": "sqlmodel",
|
|
58
|
+
"description": "ORM framework to use for the generated project.",
|
|
59
|
+
"x-priority": "important",
|
|
60
|
+
"x-prompt": "Which ORM framework would you like to use?"
|
|
61
|
+
},
|
|
62
|
+
"iac": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "The preferred IaC provider. By default this is inherited from your initial selection.",
|
|
65
|
+
"enum": ["inherit", "cdk", "terraform"],
|
|
66
|
+
"x-priority": "important",
|
|
67
|
+
"default": "inherit",
|
|
68
|
+
"x-prompt": "Which provider would you like to manage your infrastructure? (default: inherit)"
|
|
69
|
+
},
|
|
70
|
+
"preferInstallDependencies": {
|
|
71
|
+
"type": "boolean",
|
|
72
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
73
|
+
"default": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"required": ["name"]
|
|
77
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ const RDS_CA_RUN = [
|
|
5
|
+
'ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /usr/local/share/ca-certificates/rds-global-bundle.crt',
|
|
6
|
+
'RUN update-ca-certificates'
|
|
7
|
+
].join('\n');
|
|
8
|
+
export const injectRdsCaBundleIntoDockerfile = (tree, dockerfilePath)=>{
|
|
9
|
+
if (!tree.exists(dockerfilePath)) return;
|
|
10
|
+
const content = tree.read(dockerfilePath, 'utf-8');
|
|
11
|
+
if (!content) return;
|
|
12
|
+
if (content.includes('global-bundle.pem')) return;
|
|
13
|
+
tree.write(dockerfilePath, content.replace(/^(EXPOSE \d+)/m, `${RDS_CA_RUN}\n\n$1`));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/rdb/utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\n\nconst RDS_CA_RUN = [\n 'ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /usr/local/share/ca-certificates/rds-global-bundle.crt',\n 'RUN update-ca-certificates',\n].join('\\n');\n\nexport const injectRdsCaBundleIntoDockerfile = (\n tree: Tree,\n dockerfilePath: string,\n): void => {\n if (!tree.exists(dockerfilePath)) return;\n const content = tree.read(dockerfilePath, 'utf-8');\n if (!content) return;\n if (content.includes('global-bundle.pem')) return;\n tree.write(\n dockerfilePath,\n content.replace(/^(EXPOSE \\d+)/m, `${RDS_CA_RUN}\\n\\n$1`),\n );\n};\n"],"names":["RDS_CA_RUN","join","injectRdsCaBundleIntoDockerfile","tree","dockerfilePath","exists","content","read","includes","write","replace"],"mappings":"AAAA;;;CAGC,GAGD,MAAMA,aAAa;IACjB;IACA;CACD,CAACC,IAAI,CAAC;AAEP,OAAO,MAAMC,kCAAkC,CAC7CC,MACAC;IAEA,IAAI,CAACD,KAAKE,MAAM,CAACD,iBAAiB;IAClC,MAAME,UAAUH,KAAKI,IAAI,CAACH,gBAAgB;IAC1C,IAAI,CAACE,SAAS;IACd,IAAIA,QAAQE,QAAQ,CAAC,sBAAsB;IAC3CL,KAAKM,KAAK,CACRL,gBACAE,QAAQI,OAAO,CAAC,kBAAkB,GAAGV,WAAW,MAAM,CAAC;AAE3D,EAAE"}
|
package/src/sdk/py.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ export { pyMcpServerGenerator } from '../py/mcp-server/generator';
|
|
|
12
12
|
export type { PyMcpServerGeneratorSchema } from '../py/mcp-server/schema';
|
|
13
13
|
export { pyProjectGenerator } from '../py/project/generator';
|
|
14
14
|
export type { PyProjectGeneratorSchema } from '../py/project/schema';
|
|
15
|
+
export { pyRdbGenerator } from '../py/rdb/generator';
|
|
16
|
+
export type { PyRdbGeneratorSchema } from '../py/rdb/schema';
|
package/src/sdk/py.js
CHANGED
|
@@ -6,5 +6,6 @@ export { pyApiGenerator } from "../py/api/generator.js";
|
|
|
6
6
|
export { pyLambdaFunctionGenerator } from "../py/lambda-function/generator.js";
|
|
7
7
|
export { pyMcpServerGenerator } from "../py/mcp-server/generator.js";
|
|
8
8
|
export { pyProjectGenerator } from "../py/project/generator.js";
|
|
9
|
+
export { pyRdbGenerator } from "../py/rdb/generator.js";
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=py.js.map
|
package/src/sdk/py.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/py.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { pyAgentGenerator } from '../py/agent/generator';\nexport type { PyAgentGeneratorSchema } from '../py/agent/schema';\n\nexport { pyApiGenerator } from '../py/api/generator';\nexport type { PyApiGeneratorSchema } from '../py/api/schema';\n\nexport { pyLambdaFunctionGenerator } from '../py/lambda-function/generator';\nexport type { PyLambdaFunctionGeneratorSchema } from '../py/lambda-function/schema';\n\nexport { pyMcpServerGenerator } from '../py/mcp-server/generator';\nexport type { PyMcpServerGeneratorSchema } from '../py/mcp-server/schema';\nexport { pyProjectGenerator } from '../py/project/generator';\nexport type { PyProjectGeneratorSchema } from '../py/project/schema';\n"],"names":["pyAgentGenerator","pyApiGenerator","pyLambdaFunctionGenerator","pyMcpServerGenerator","pyProjectGenerator"],"mappings":"AAAA;;;CAGC,GAED,SAASA,gBAAgB,QAAQ,2BAAwB;AAGzD,SAASC,cAAc,QAAQ,yBAAsB;AAGrD,SAASC,yBAAyB,QAAQ,qCAAkC;AAG5E,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,SAASC,kBAAkB,QAAQ,6BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/py.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { pyAgentGenerator } from '../py/agent/generator';\nexport type { PyAgentGeneratorSchema } from '../py/agent/schema';\n\nexport { pyApiGenerator } from '../py/api/generator';\nexport type { PyApiGeneratorSchema } from '../py/api/schema';\n\nexport { pyLambdaFunctionGenerator } from '../py/lambda-function/generator';\nexport type { PyLambdaFunctionGeneratorSchema } from '../py/lambda-function/schema';\n\nexport { pyMcpServerGenerator } from '../py/mcp-server/generator';\nexport type { PyMcpServerGeneratorSchema } from '../py/mcp-server/schema';\nexport { pyProjectGenerator } from '../py/project/generator';\nexport type { PyProjectGeneratorSchema } from '../py/project/schema';\n\nexport { pyRdbGenerator } from '../py/rdb/generator';\nexport type { PyRdbGeneratorSchema } from '../py/rdb/schema';\n"],"names":["pyAgentGenerator","pyApiGenerator","pyLambdaFunctionGenerator","pyMcpServerGenerator","pyProjectGenerator","pyRdbGenerator"],"mappings":"AAAA;;;CAGC,GAED,SAASA,gBAAgB,QAAQ,2BAAwB;AAGzD,SAASC,cAAc,QAAQ,yBAAsB;AAGrD,SAASC,yBAAyB,QAAQ,qCAAkC;AAG5E,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,SAASC,kBAAkB,QAAQ,6BAA0B;AAG7D,SAASC,cAAc,QAAQ,yBAAsB"}
|
|
@@ -684,6 +684,18 @@ variable "additional_iam_policy_statements" {
|
|
|
684
684
|
default = []
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
+
variable "appconfig_application_id" {
|
|
688
|
+
description = "ID of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_id\`). When set, the Lambda functions receive \`RUNTIME_CONFIG_APP_ID\` and read access to the application."
|
|
689
|
+
type = string
|
|
690
|
+
default = null
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
variable "appconfig_application_arn" {
|
|
694
|
+
description = "ARN of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_arn\`). Used to scope the IAM read permission granted to the Lambda functions."
|
|
695
|
+
type = string
|
|
696
|
+
default = null
|
|
697
|
+
}
|
|
698
|
+
|
|
687
699
|
variable "asset_bucket_name" {
|
|
688
700
|
description = "Name of the shared asset S3 bucket used to stage the Lambda deployment zip. Instantiate the \`core/asset-bucket\` module once per deployment and pass its \`bucket_name\` output here."
|
|
689
701
|
type = string
|
|
@@ -866,7 +878,9 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
866
878
|
|
|
867
879
|
environment {
|
|
868
880
|
variables = merge({
|
|
869
|
-
}, var.
|
|
881
|
+
}, var.appconfig_application_id != null ? {
|
|
882
|
+
RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
|
|
883
|
+
} : {}, var.env)
|
|
870
884
|
}
|
|
871
885
|
|
|
872
886
|
tags = var.tags
|
|
@@ -915,16 +929,30 @@ resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
|
915
929
|
|
|
916
930
|
# Additional IAM policies for Lambda (if provided)
|
|
917
931
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
918
|
-
count = length(
|
|
932
|
+
count = length(local.lambda_policy_statements) > 0 ? 1 : 0
|
|
919
933
|
name = "TestApiHandler-additional-policies-\${random_string.suffix.result}"
|
|
920
934
|
role = aws_iam_role.lambda_execution_role.id
|
|
921
935
|
|
|
922
936
|
policy = jsonencode({
|
|
923
937
|
Version = "2012-10-17"
|
|
924
|
-
Statement =
|
|
938
|
+
Statement = local.lambda_policy_statements
|
|
925
939
|
})
|
|
926
940
|
}
|
|
927
941
|
|
|
942
|
+
locals {
|
|
943
|
+
# Grant read access to the runtime-config AppConfig application when wired
|
|
944
|
+
lambda_policy_statements = concat(var.appconfig_application_arn != null ? [
|
|
945
|
+
{
|
|
946
|
+
Effect = "Allow"
|
|
947
|
+
Action = [
|
|
948
|
+
"appconfig:StartConfigurationSession",
|
|
949
|
+
"appconfig:GetLatestConfiguration"
|
|
950
|
+
]
|
|
951
|
+
Resource = ["\${var.appconfig_application_arn}/*"]
|
|
952
|
+
}
|
|
953
|
+
] : [], var.additional_iam_policy_statements)
|
|
954
|
+
}
|
|
955
|
+
|
|
928
956
|
# CloudWatch Log Group for Lambda
|
|
929
957
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
930
958
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -2115,6 +2143,18 @@ variable "additional_iam_policy_statements" {
|
|
|
2115
2143
|
default = []
|
|
2116
2144
|
}
|
|
2117
2145
|
|
|
2146
|
+
variable "appconfig_application_id" {
|
|
2147
|
+
description = "ID of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_id\`). When set, the Lambda functions receive \`RUNTIME_CONFIG_APP_ID\` and read access to the application."
|
|
2148
|
+
type = string
|
|
2149
|
+
default = null
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
variable "appconfig_application_arn" {
|
|
2153
|
+
description = "ARN of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_arn\`). Used to scope the IAM read permission granted to the Lambda functions."
|
|
2154
|
+
type = string
|
|
2155
|
+
default = null
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2118
2158
|
variable "asset_bucket_name" {
|
|
2119
2159
|
description = "Name of the shared asset S3 bucket used to stage the Lambda deployment zip. Instantiate the \`core/asset-bucket\` module once per deployment and pass its \`bucket_name\` output here."
|
|
2120
2160
|
type = string
|
|
@@ -2297,7 +2337,9 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
2297
2337
|
|
|
2298
2338
|
environment {
|
|
2299
2339
|
variables = merge({
|
|
2300
|
-
}, var.
|
|
2340
|
+
}, var.appconfig_application_id != null ? {
|
|
2341
|
+
RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
|
|
2342
|
+
} : {}, var.env)
|
|
2301
2343
|
}
|
|
2302
2344
|
|
|
2303
2345
|
tags = var.tags
|
|
@@ -2346,16 +2388,30 @@ resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
|
2346
2388
|
|
|
2347
2389
|
# Additional IAM policies for Lambda (if provided)
|
|
2348
2390
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
2349
|
-
count = length(
|
|
2391
|
+
count = length(local.lambda_policy_statements) > 0 ? 1 : 0
|
|
2350
2392
|
name = "TestApiHandler-additional-policies-\${random_string.suffix.result}"
|
|
2351
2393
|
role = aws_iam_role.lambda_execution_role.id
|
|
2352
2394
|
|
|
2353
2395
|
policy = jsonencode({
|
|
2354
2396
|
Version = "2012-10-17"
|
|
2355
|
-
Statement =
|
|
2397
|
+
Statement = local.lambda_policy_statements
|
|
2356
2398
|
})
|
|
2357
2399
|
}
|
|
2358
2400
|
|
|
2401
|
+
locals {
|
|
2402
|
+
# Grant read access to the runtime-config AppConfig application when wired
|
|
2403
|
+
lambda_policy_statements = concat(var.appconfig_application_arn != null ? [
|
|
2404
|
+
{
|
|
2405
|
+
Effect = "Allow"
|
|
2406
|
+
Action = [
|
|
2407
|
+
"appconfig:StartConfigurationSession",
|
|
2408
|
+
"appconfig:GetLatestConfiguration"
|
|
2409
|
+
]
|
|
2410
|
+
Resource = ["\${var.appconfig_application_arn}/*"]
|
|
2411
|
+
}
|
|
2412
|
+
] : [], var.additional_iam_policy_statements)
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2359
2415
|
# CloudWatch Log Group for Lambda
|
|
2360
2416
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
2361
2417
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -3052,6 +3108,18 @@ variable "additional_iam_policy_statements" {
|
|
|
3052
3108
|
default = []
|
|
3053
3109
|
}
|
|
3054
3110
|
|
|
3111
|
+
variable "appconfig_application_id" {
|
|
3112
|
+
description = "ID of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_id\`). When set, the Lambda functions receive \`RUNTIME_CONFIG_APP_ID\` and read access to the application."
|
|
3113
|
+
type = string
|
|
3114
|
+
default = null
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
variable "appconfig_application_arn" {
|
|
3118
|
+
description = "ARN of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_arn\`). Used to scope the IAM read permission granted to the Lambda functions."
|
|
3119
|
+
type = string
|
|
3120
|
+
default = null
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3055
3123
|
variable "asset_bucket_name" {
|
|
3056
3124
|
description = "Name of the shared asset S3 bucket used to stage the Lambda deployment zip. Instantiate the \`core/asset-bucket\` module once per deployment and pass its \`bucket_name\` output here."
|
|
3057
3125
|
type = string
|
|
@@ -3234,7 +3302,9 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
3234
3302
|
|
|
3235
3303
|
environment {
|
|
3236
3304
|
variables = merge({
|
|
3237
|
-
}, var.
|
|
3305
|
+
}, var.appconfig_application_id != null ? {
|
|
3306
|
+
RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
|
|
3307
|
+
} : {}, var.env)
|
|
3238
3308
|
}
|
|
3239
3309
|
|
|
3240
3310
|
tags = var.tags
|
|
@@ -3283,16 +3353,30 @@ resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
|
3283
3353
|
|
|
3284
3354
|
# Additional IAM policies for Lambda (if provided)
|
|
3285
3355
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
3286
|
-
count = length(
|
|
3356
|
+
count = length(local.lambda_policy_statements) > 0 ? 1 : 0
|
|
3287
3357
|
name = "TestApiHandler-additional-policies-\${random_string.suffix.result}"
|
|
3288
3358
|
role = aws_iam_role.lambda_execution_role.id
|
|
3289
3359
|
|
|
3290
3360
|
policy = jsonencode({
|
|
3291
3361
|
Version = "2012-10-17"
|
|
3292
|
-
Statement =
|
|
3362
|
+
Statement = local.lambda_policy_statements
|
|
3293
3363
|
})
|
|
3294
3364
|
}
|
|
3295
3365
|
|
|
3366
|
+
locals {
|
|
3367
|
+
# Grant read access to the runtime-config AppConfig application when wired
|
|
3368
|
+
lambda_policy_statements = concat(var.appconfig_application_arn != null ? [
|
|
3369
|
+
{
|
|
3370
|
+
Effect = "Allow"
|
|
3371
|
+
Action = [
|
|
3372
|
+
"appconfig:StartConfigurationSession",
|
|
3373
|
+
"appconfig:GetLatestConfiguration"
|
|
3374
|
+
]
|
|
3375
|
+
Resource = ["\${var.appconfig_application_arn}/*"]
|
|
3376
|
+
}
|
|
3377
|
+
] : [], var.additional_iam_policy_statements)
|
|
3378
|
+
}
|
|
3379
|
+
|
|
3296
3380
|
# CloudWatch Log Group for Lambda
|
|
3297
3381
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
3298
3382
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|
|
@@ -3728,6 +3812,18 @@ variable "additional_iam_policy_statements" {
|
|
|
3728
3812
|
default = []
|
|
3729
3813
|
}
|
|
3730
3814
|
|
|
3815
|
+
variable "appconfig_application_id" {
|
|
3816
|
+
description = "ID of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_id\`). When set, the Lambda functions receive \`RUNTIME_CONFIG_APP_ID\` and read access to the application."
|
|
3817
|
+
type = string
|
|
3818
|
+
default = null
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
variable "appconfig_application_arn" {
|
|
3822
|
+
description = "ARN of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_arn\`). Used to scope the IAM read permission granted to the Lambda functions."
|
|
3823
|
+
type = string
|
|
3824
|
+
default = null
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3731
3827
|
variable "asset_bucket_name" {
|
|
3732
3828
|
description = "Name of the shared asset S3 bucket used to stage the Lambda deployment zip. Instantiate the \`core/asset-bucket\` module once per deployment and pass its \`bucket_name\` output here."
|
|
3733
3829
|
type = string
|
|
@@ -3910,7 +4006,9 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
3910
4006
|
|
|
3911
4007
|
environment {
|
|
3912
4008
|
variables = merge({
|
|
3913
|
-
}, var.
|
|
4009
|
+
}, var.appconfig_application_id != null ? {
|
|
4010
|
+
RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
|
|
4011
|
+
} : {}, var.env)
|
|
3914
4012
|
}
|
|
3915
4013
|
|
|
3916
4014
|
tags = var.tags
|
|
@@ -3959,16 +4057,30 @@ resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
|
3959
4057
|
|
|
3960
4058
|
# Additional IAM policies for Lambda (if provided)
|
|
3961
4059
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
3962
|
-
count = length(
|
|
4060
|
+
count = length(local.lambda_policy_statements) > 0 ? 1 : 0
|
|
3963
4061
|
name = "CustomApiHandler-additional-policies-\${random_string.suffix.result}"
|
|
3964
4062
|
role = aws_iam_role.lambda_execution_role.id
|
|
3965
4063
|
|
|
3966
4064
|
policy = jsonencode({
|
|
3967
4065
|
Version = "2012-10-17"
|
|
3968
|
-
Statement =
|
|
4066
|
+
Statement = local.lambda_policy_statements
|
|
3969
4067
|
})
|
|
3970
4068
|
}
|
|
3971
4069
|
|
|
4070
|
+
locals {
|
|
4071
|
+
# Grant read access to the runtime-config AppConfig application when wired
|
|
4072
|
+
lambda_policy_statements = concat(var.appconfig_application_arn != null ? [
|
|
4073
|
+
{
|
|
4074
|
+
Effect = "Allow"
|
|
4075
|
+
Action = [
|
|
4076
|
+
"appconfig:StartConfigurationSession",
|
|
4077
|
+
"appconfig:GetLatestConfiguration"
|
|
4078
|
+
]
|
|
4079
|
+
Resource = ["\${var.appconfig_application_arn}/*"]
|
|
4080
|
+
}
|
|
4081
|
+
] : [], var.additional_iam_policy_statements)
|
|
4082
|
+
}
|
|
4083
|
+
|
|
3972
4084
|
# CloudWatch Log Group for Lambda
|
|
3973
4085
|
resource "aws_cloudwatch_log_group" "lambda_logs" {
|
|
3974
4086
|
#checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
|