@aws/nx-plugin 0.75.0 → 0.77.0
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 +60 -2
- package/README.md +5 -0
- package/package.json +9 -9
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +378 -7
- package/src/infra/app/files/app/src/main.ts.template +17 -2
- package/src/infra/app/generator.js +34 -9
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.ts +1 -0
- package/src/infra/app/schema.json +6 -0
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +21 -4
- package/src/py/mcp-server/files/app/http.py.template +18 -2
- package/src/py/mcp-server/files/deploy/Dockerfile.template +1 -1
- package/src/py/mcp-server/generator.js +4 -2
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/nx-plugin/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +13 -13
- package/src/utils/files/common/infra-config/src/index.ts.template +3 -0
- package/src/utils/files/common/infra-config/src/resolve-stage.ts.template +23 -0
- package/src/utils/files/common/infra-config/src/stages.config.ts.template +48 -0
- package/src/utils/files/common/infra-config/src/stages.types.ts.template +66 -0
- package/src/utils/files/common/scripts/src/index.ts.template +1 -0
- package/src/utils/files/common/scripts/src/infra-deploy.ts.template +2 -0
- package/src/utils/files/common/scripts/src/infra-destroy.ts.template +2 -0
- package/src/utils/files/common/scripts/src/stage-credentials/cdk-command.ts.template +18 -0
- package/src/utils/files/common/scripts/src/stage-credentials/credentials.ts.template +100 -0
- package/src/utils/files/common/scripts/src/stage-credentials/run.ts.template +52 -0
- package/src/utils/files/common/scripts/src/stage-credentials/stage-parser.ts.template +15 -0
- package/src/utils/shared-constructs-constants.d.ts +4 -0
- package/src/utils/shared-constructs-constants.js +5 -1
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-infra-config.d.ts +11 -0
- package/src/utils/shared-infra-config.js +47 -0
- package/src/utils/shared-infra-config.js.map +1 -0
- package/src/utils/shared-scripts.d.ts +12 -0
- package/src/utils/shared-scripts.js +49 -0
- package/src/utils/shared-scripts.js.map +1 -0
- package/src/utils/versions.d.ts +29 -28
- package/src/utils/versions.js +28 -27
- package/src/utils/versions.js.map +1 -1
|
@@ -12,6 +12,8 @@ const generator_1 = tslib_1.__importStar(require("../../ts/lib/generator"));
|
|
|
12
12
|
const versions_1 = require("../../utils/versions");
|
|
13
13
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
14
14
|
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
15
|
+
const shared_infra_config_1 = require("../../utils/shared-infra-config");
|
|
16
|
+
const shared_scripts_1 = require("../../utils/shared-scripts");
|
|
15
17
|
const shared_constructs_constants_1 = require("../../utils/shared-constructs-constants");
|
|
16
18
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
17
19
|
const format_1 = require("../../utils/format");
|
|
@@ -23,6 +25,7 @@ const py_1 = require("../../utils/py");
|
|
|
23
25
|
exports.INFRA_APP_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
24
26
|
function tsInfraGenerator(tree, schema) {
|
|
25
27
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var _a;
|
|
26
29
|
const lib = (0, generator_1.getTsLibDetails)(tree, schema);
|
|
27
30
|
yield (0, generator_1.default)(tree, schema);
|
|
28
31
|
(0, nx_1.addGeneratorMetadata)(tree, lib.fullyQualifiedName, exports.INFRA_APP_GENERATOR_INFO);
|
|
@@ -30,6 +33,13 @@ function tsInfraGenerator(tree, schema) {
|
|
|
30
33
|
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree, {
|
|
31
34
|
iacProvider: 'CDK',
|
|
32
35
|
});
|
|
36
|
+
// Shared infra-config and infra-scripts packages (lazy creation, only when enabled)
|
|
37
|
+
const enableStageConfig = (_a = schema.enableStageConfig) !== null && _a !== void 0 ? _a : false;
|
|
38
|
+
if (enableStageConfig) {
|
|
39
|
+
yield (0, shared_infra_config_1.sharedInfraConfigGenerator)(tree);
|
|
40
|
+
yield (0, shared_scripts_1.sharedScriptsGenerator)(tree);
|
|
41
|
+
}
|
|
42
|
+
const synthDirFromRoot = `/dist/${lib.dir}/cdk.out`;
|
|
33
43
|
const synthDirFromProject = lib.dir
|
|
34
44
|
.split('/')
|
|
35
45
|
.map(() => '..')
|
|
@@ -46,7 +56,7 @@ function tsInfraGenerator(tree, schema) {
|
|
|
46
56
|
tree.delete((0, devkit_1.joinPathFragments)(libraryRoot, 'src'));
|
|
47
57
|
(0, devkit_1.generateFiles)(tree, // the virtual file system
|
|
48
58
|
(0, devkit_1.joinPathFragments)(__dirname, './files/app'), // path to the file templates
|
|
49
|
-
libraryRoot, Object.assign({ synthDir: synthDirFromProject, scopeAlias: scopeAlias, namespace: (0, names_1.kebabCase)(fullyQualifiedName), fullyQualifiedName, pkgMgrCmd: (0, devkit_1.getPackageManagerCommand)().exec, dir: lib.dir }, schema), {
|
|
59
|
+
libraryRoot, Object.assign({ synthDir: synthDirFromProject, scopeAlias: scopeAlias, namespace: (0, names_1.kebabCase)(fullyQualifiedName), fullyQualifiedName, pkgMgrCmd: (0, devkit_1.getPackageManagerCommand)().exec, dir: lib.dir, enableStageConfig }, schema), {
|
|
50
60
|
overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
|
|
51
61
|
});
|
|
52
62
|
(0, devkit_1.updateJson)(tree, `${libraryRoot}/project.json`, (config) => {
|
|
@@ -84,10 +94,14 @@ function tsInfraGenerator(tree, schema) {
|
|
|
84
94
|
config.targets.deploy = {
|
|
85
95
|
executor: 'nx:run-commands',
|
|
86
96
|
dependsOn: ['^build', 'compile'],
|
|
87
|
-
options:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
options: enableStageConfig
|
|
98
|
+
? {
|
|
99
|
+
command: `tsx packages/common/scripts/src/infra-deploy.ts ${libraryRoot}`,
|
|
100
|
+
}
|
|
101
|
+
: {
|
|
102
|
+
cwd: '{projectRoot}',
|
|
103
|
+
command: 'cdk deploy --require-approval=never',
|
|
104
|
+
},
|
|
91
105
|
};
|
|
92
106
|
config.targets['deploy-ci'] = {
|
|
93
107
|
executor: 'nx:run-commands',
|
|
@@ -99,10 +113,14 @@ function tsInfraGenerator(tree, schema) {
|
|
|
99
113
|
config.targets.destroy = {
|
|
100
114
|
executor: 'nx:run-commands',
|
|
101
115
|
dependsOn: ['^build', 'compile'],
|
|
102
|
-
options:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
options: enableStageConfig
|
|
117
|
+
? {
|
|
118
|
+
command: `tsx packages/common/scripts/src/infra-destroy.ts ${libraryRoot}`,
|
|
119
|
+
}
|
|
120
|
+
: {
|
|
121
|
+
cwd: '{projectRoot}',
|
|
122
|
+
command: 'cdk destroy --require-approval=never',
|
|
123
|
+
},
|
|
106
124
|
};
|
|
107
125
|
config.targets['destroy-ci'] = {
|
|
108
126
|
executor: 'nx:run-commands',
|
|
@@ -140,6 +158,13 @@ function tsInfraGenerator(tree, schema) {
|
|
|
140
158
|
{
|
|
141
159
|
path: `${path_1.default.relative(libraryRoot, `${tree.root}/${shared_constructs_constants_1.PACKAGES_DIR}`)}/${shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR}/tsconfig.lib.json`,
|
|
142
160
|
},
|
|
161
|
+
...(enableStageConfig
|
|
162
|
+
? [
|
|
163
|
+
{
|
|
164
|
+
path: `${path_1.default.relative(libraryRoot, `${tree.root}/${shared_constructs_constants_1.PACKAGES_DIR}`)}/${shared_constructs_constants_1.SHARED_INFRA_CONFIG_DIR}/tsconfig.json`,
|
|
165
|
+
},
|
|
166
|
+
]
|
|
167
|
+
: []),
|
|
143
168
|
] })));
|
|
144
169
|
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [exports.INFRA_APP_GENERATOR_INFO]);
|
|
145
170
|
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;;AA4CA,4CAiMC;;AA7OD;;;GAGG;AACH,uCAYoB;AAEpB,4EAA6E;AAC7E,mDAAoD;AACpD,qDAAwE;AACxE,qEAA0E;AAC1E,yEAA6E;AAC7E,+DAAoE;AACpE,yFAIiD;AACjD,wDAAwB;AACxB,+CAA0D;AAC1D,+CAAoD;AACpD,uCAIwB;AACxB,iDAAsE;AACtE,6CAA8C;AAC9C,uCAA4C;AAE/B,QAAA,wBAAwB,GACnC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B,SAAsB,gBAAgB,CACpC,IAAU,EACV,MAA8B;;;QAE9B,MAAM,GAAG,GAAG,IAAA,2BAAe,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,IAAA,mBAAkB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEvC,IAAA,yBAAoB,EAAC,IAAI,EAAE,GAAG,CAAC,kBAAkB,EAAE,gCAAwB,CAAC,CAAC;QAE7E,iEAAiE;QACjE,MAAM,IAAA,6CAAyB,EAAC,IAAI,EAAE;YACpC,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;QAEH,oFAAoF;QACpF,MAAM,iBAAiB,GAAG,MAAA,MAAM,CAAC,iBAAiB,mCAAI,KAAK,CAAC;QAC5D,IAAI,iBAAiB,EAAE,CAAC;YACtB,MAAM,IAAA,gDAA0B,EAAC,IAAI,CAAC,CAAC;YACvC,MAAM,IAAA,uCAAsB,EAAC,IAAI,CAAC,CAAC;QACrC,CAAC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AAC,CACF,CAAC;QAEF,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;YACX,aAAa;YACb,SAAS;YACT,SAAS;YACT,YAAY;YACZ,oBAAoB;SACrB,CAAC,EACF,IAAA,uBAAY,EAAC,CAAC,KAAK,CAAC,CAAC,CACtB,CAAC;QAEF,IAAA,mBAAU,EAAC,IAAI,EAAE,GAAG,WAAW,oBAAoB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,iCAC9D,QAAQ,KACX,UAAU,EAAE;gBACV,GAAG,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;gBAC9B;oBACE,IAAI,EAAE,GAAG,cAAI,CAAC,QAAQ,CACpB,WAAW,EACX,GAAG,IAAI,CAAC,IAAI,IAAI,0CAAY,EAAE,CAC/B,IAAI,mDAAqB,oBAAoB;iBAC/C;gBACD,GAAG,CAAC,iBAAiB;oBACnB,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,GAAG,cAAI,CAAC,QAAQ,CACpB,WAAW,EACX,GAAG,IAAI,CAAC,IAAI,IAAI,0CAAY,EAAE,CAC/B,IAAI,qDAAuB,gBAAgB;yBAC7C;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR,IACD,CAAC,CAAC;QAEJ,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE,CAAC,gCAAwB,CAAC,CAAC,CAAC;QAExE,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,gBAAgB,CAAC"}
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
"x-priority": "important",
|
|
22
22
|
"default": "packages",
|
|
23
23
|
"x-prompt": "What directory would you like to store your application in?"
|
|
24
|
+
},
|
|
25
|
+
"enableStageConfig": {
|
|
26
|
+
"description": "Enable centralized stage configuration (credentials, account, region) for multi-environment CDK deployments.",
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"default": false,
|
|
29
|
+
"x-prompt": "Would you like to enable centralized stage credential configuration?"
|
|
24
30
|
}
|
|
25
31
|
},
|
|
26
32
|
"required": ["name"]
|
|
@@ -498,10 +498,26 @@ output "agent_core_runtime_arn" {
|
|
|
498
498
|
exports[`py#mcp-server generator > should match snapshot for generated files > mcp-server-__init__.py 1`] = `""`;
|
|
499
499
|
|
|
500
500
|
exports[`py#mcp-server generator > should match snapshot for generated files > mcp-server-http.py 1`] = `
|
|
501
|
-
"
|
|
501
|
+
"import contextlib
|
|
502
502
|
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
from starlette.applications import Starlette
|
|
504
|
+
from starlette.routing import Mount
|
|
505
|
+
|
|
506
|
+
from .server import mcp
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
@contextlib.asynccontextmanager
|
|
510
|
+
async def lifespan(app: Starlette):
|
|
511
|
+
async with mcp.session_manager.run():
|
|
512
|
+
yield
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
app = Starlette(
|
|
516
|
+
routes=[
|
|
517
|
+
Mount("/", app=mcp.streamable_http_app()),
|
|
518
|
+
],
|
|
519
|
+
lifespan=lifespan,
|
|
520
|
+
)
|
|
505
521
|
"
|
|
506
522
|
`;
|
|
507
523
|
|
|
@@ -546,7 +562,8 @@ name = "proj.test_project"
|
|
|
546
562
|
version = "0.1.0"
|
|
547
563
|
dependencies = [
|
|
548
564
|
"mcp==1.26.0",
|
|
549
|
-
"
|
|
565
|
+
"uvicorn==0.41.0",
|
|
566
|
+
"boto3==1.42.54",
|
|
550
567
|
"aws-opentelemetry-distro==0.15.0"
|
|
551
568
|
]
|
|
552
569
|
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
|
|
3
|
+
from starlette.applications import Starlette
|
|
4
|
+
from starlette.routing import Mount
|
|
5
|
+
|
|
1
6
|
from .server import mcp
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
|
|
9
|
+
@contextlib.asynccontextmanager
|
|
10
|
+
async def lifespan(app: Starlette):
|
|
11
|
+
async with mcp.session_manager.run():
|
|
12
|
+
yield
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
app = Starlette(
|
|
16
|
+
routes=[
|
|
17
|
+
Mount("/", app=mcp.streamable_http_app()),
|
|
18
|
+
],
|
|
19
|
+
lifespan=lifespan,
|
|
20
|
+
)
|
|
@@ -11,4 +11,4 @@ ENV PYTHONPATH=/app
|
|
|
11
11
|
|
|
12
12
|
# Auto-instrument with AWS Distro for OpenTelemetry
|
|
13
13
|
# https://aws-otel.github.io/docs/getting-started/python-sdk/auto-instr
|
|
14
|
-
CMD ["python", "bin/opentelemetry-instrument", "python", "-m", "<%- moduleName %>.<%- mcpServerNameSnakeCase %>.http"]
|
|
14
|
+
CMD ["python", "bin/opentelemetry-instrument", "python", "-m", "uvicorn", "<%- moduleName %>.<%- mcpServerNameSnakeCase %>.http:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
@@ -50,6 +50,7 @@ const pyMcpServerGenerator = (tree, options) => tslib_1.__awaiter(void 0, void 0
|
|
|
50
50
|
}, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
51
51
|
(0, py_1.addDependenciesToPyProjectToml)(tree, project.root, [
|
|
52
52
|
'mcp',
|
|
53
|
+
'uvicorn',
|
|
53
54
|
'boto3',
|
|
54
55
|
'aws-opentelemetry-distro',
|
|
55
56
|
]);
|
|
@@ -110,8 +111,9 @@ const pyMcpServerGenerator = (tree, options) => tslib_1.__awaiter(void 0, void 0
|
|
|
110
111
|
}, [`${mcpTargetPrefix}-serve`]: {
|
|
111
112
|
executor: 'nx:run-commands',
|
|
112
113
|
options: {
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
commands: [
|
|
115
|
+
`uv run uvicorn --reload ${moduleName}.${mcpServerNameSnakeCase}.http:app --host 0.0.0.0 --port ${localDevPort}`,
|
|
116
|
+
],
|
|
115
117
|
cwd: '{projectRoot}',
|
|
116
118
|
env: {
|
|
117
119
|
PORT: `${localDevPort}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/py/mcp-server/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,uCAKwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,6CAAwE;AACxE,uCAAgE;AAChE,qDAAoD;AACpD,mGAA4F;AAC5F,qEAA0E;AAC1E,sDAAkE;AAClE,mDAAoD;AACpD,yDAA6D;AAC7D,yCAAqD;AACrD,2CAA8C;AAEjC,QAAA,4BAA4B,GACvC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAClC,IAAU,EACV,OAAmC,EACP,EAAE;;IAC9B,MAAM,OAAO,GAAG,IAAA,wCAAmC,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3E,MAAM,aAAa,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAExE,iDAAiD;IACjD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,uBAAuB,OAAO,CAAC,OAAO,qDAAqD,CAC5F,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,gIAAgI,CACjI,CAAC;IACJ,CAAC;IAED,mDAAmD;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEvD,MAAM,IAAI,GAAG,IAAA,iBAAS,EACpB,OAAO,CAAC,I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EAAE,CAAC,CAAC;QAEvD,6CAA6C;QAC7C,IAAA,yCAAiB,EAAC,IAAI,EAAE;YACtB,sBAAsB,EAAE,IAAI;YAC5B,sBAAsB;YACtB,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,cAAc;YACd,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED,MAAM,YAAY,GAAG,IAAA,iBAAU,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAErD,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,kCACxC,OAAO,KACV,OAAO,kCACF,OAAO,CAAC,OAAO;YAClB,yCAAyC;YACzC,CAAC,GAAG,eAAe,cAAc,CAAC,EAAE;gBAClC,QAAQ,EAAE,iBAAiB;gBAC3B,OAAO,EAAE;oBACP,QAAQ,EAAE,CAAC,aAAa,UAAU,IAAI,sBAAsB,QAAQ,CAAC;oBACrE,GAAG,EAAE,eAAe;iBACrB;gBACD,UAAU,EAAE,IAAI;aACjB,EACD,CAAC,GAAG,eAAe,QAAQ,CAAC,EAAE;gBAC5B,QAAQ,EAAE,iBAAiB;gBAC3B,OAAO,EAAE;oBACP,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/py/mcp-server/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,uCAKwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,6CAAwE;AACxE,uCAAgE;AAChE,qDAAoD;AACpD,mGAA4F;AAC5F,qEAA0E;AAC1E,sDAAkE;AAClE,mDAAoD;AACpD,yDAA6D;AAC7D,yCAAqD;AACrD,2CAA8C;AAEjC,QAAA,4BAA4B,GACvC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAClC,IAAU,EACV,OAAmC,EACP,EAAE;;IAC9B,MAAM,OAAO,GAAG,IAAA,wCAAmC,EAAC,IAAI,EAA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|
|
|
589
589
|
dependencies = [
|
|
590
590
|
"aws-opentelemetry-distro==0.15.0",
|
|
591
591
|
"bedrock-agentcore==0.1.7",
|
|
592
|
-
"fastapi==0.
|
|
593
|
-
"boto3==1.42.
|
|
592
|
+
"fastapi==0.131.0",
|
|
593
|
+
"boto3==1.42.54",
|
|
594
594
|
"mcp==1.26.0",
|
|
595
|
-
"strands-agents==1.
|
|
596
|
-
"strands-agents-tools==0.2.
|
|
597
|
-
"uvicorn==0.
|
|
595
|
+
"strands-agents==1.27.0",
|
|
596
|
+
"strands-agents-tools==0.2.21",
|
|
597
|
+
"uvicorn==0.41.0"
|
|
598
598
|
]
|
|
599
599
|
|
|
600
600
|
[dependency-groups]
|
|
601
|
-
dev = [ "fastapi[standard]==0.
|
|
601
|
+
dev = [ "fastapi[standard]==0.131.0" ]
|
|
602
602
|
|
|
603
603
|
[tool.uv]
|
|
604
604
|
dev-dependencies = [ ]
|
|
@@ -640,7 +640,7 @@ exports[`ts#mcp-server generator > should match snapshot for generated files > u
|
|
|
640
640
|
"snapshot-server": "./src/snapshot-server/stdio.js"
|
|
641
641
|
},
|
|
642
642
|
"dependencies": {
|
|
643
|
-
"@modelcontextprotocol/sdk": "1.
|
|
643
|
+
"@modelcontextprotocol/sdk": "1.27.0",
|
|
644
644
|
"express": "5.2.1",
|
|
645
645
|
"zod": "4.3.6"
|
|
646
646
|
},
|
|
@@ -248,7 +248,7 @@ export const registerCreateWorkspaceCommandTool = (server: McpServer) => {
|
|
|
248
248
|
text: \`Run the following command to create a workspace:
|
|
249
249
|
|
|
250
250
|
\\\`\\\`\\\`bash
|
|
251
|
-
npx create-nx-workspace@22.5.
|
|
251
|
+
npx create-nx-workspace@22.5.1 \${workspaceName} --pm=\${packageManager} --preset=@aws/nx-plugin --ci=skip --aiAgents
|
|
252
252
|
\\\`\\\`\\\`
|
|
253
253
|
|
|
254
254
|
This will create a new workspace within the \${workspaceName} directory.
|
|
@@ -1045,11 +1045,11 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1045
1045
|
"{
|
|
1046
1046
|
"name": "@proj/source",
|
|
1047
1047
|
"dependencies": {
|
|
1048
|
-
"@cloudscape-design/board-components": "3.0.
|
|
1049
|
-
"@cloudscape-design/components": "3.0.
|
|
1048
|
+
"@cloudscape-design/board-components": "3.0.149",
|
|
1049
|
+
"@cloudscape-design/components": "3.0.1204",
|
|
1050
1050
|
"@cloudscape-design/global-styles": "1.0.50",
|
|
1051
1051
|
"aws-cdk-lib": "2.238.0",
|
|
1052
|
-
"constructs": "10.
|
|
1052
|
+
"constructs": "10.5.0",
|
|
1053
1053
|
"react": "19.2.4",
|
|
1054
1054
|
"react-dom": "19.2.4",
|
|
1055
1055
|
"tailwindcss": "4.1.18"
|
|
@@ -2460,12 +2460,12 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2460
2460
|
"{
|
|
2461
2461
|
"name": "@proj/source",
|
|
2462
2462
|
"dependencies": {
|
|
2463
|
-
"@cloudscape-design/board-components": "3.0.
|
|
2464
|
-
"@cloudscape-design/components": "3.0.
|
|
2463
|
+
"@cloudscape-design/board-components": "3.0.149",
|
|
2464
|
+
"@cloudscape-design/components": "3.0.1204",
|
|
2465
2465
|
"@cloudscape-design/global-styles": "1.0.50",
|
|
2466
|
-
"@tanstack/react-router": "1.
|
|
2466
|
+
"@tanstack/react-router": "1.160.2",
|
|
2467
2467
|
"aws-cdk-lib": "2.238.0",
|
|
2468
|
-
"constructs": "10.
|
|
2468
|
+
"constructs": "10.5.0",
|
|
2469
2469
|
"react": "19.2.4",
|
|
2470
2470
|
"react-dom": "19.2.4",
|
|
2471
2471
|
"tailwindcss": "4.1.18"
|
|
@@ -2484,8 +2484,8 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2484
2484
|
"@swc/core": "~1.15.5",
|
|
2485
2485
|
"@swc/helpers": "~0.5.18",
|
|
2486
2486
|
"@tailwindcss/vite": "4.1.18",
|
|
2487
|
-
"@tanstack/router-generator": "1.
|
|
2488
|
-
"@tanstack/router-plugin": "1.
|
|
2487
|
+
"@tanstack/router-generator": "1.160.1",
|
|
2488
|
+
"@tanstack/router-plugin": "1.160.2",
|
|
2489
2489
|
"@tanstack/router-utils": "1.158.0",
|
|
2490
2490
|
"@tanstack/virtual-file-routes": "1.154.7",
|
|
2491
2491
|
"@testing-library/dom": "10.4.0",
|
|
@@ -4529,12 +4529,12 @@ root &&
|
|
|
4529
4529
|
|
|
4530
4530
|
exports[`react-website generator > should handle npm scope prefix correctly > scoped-dependencies 1`] = `
|
|
4531
4531
|
{
|
|
4532
|
-
"@cloudscape-design/board-components": "3.0.
|
|
4533
|
-
"@cloudscape-design/components": "3.0.
|
|
4532
|
+
"@cloudscape-design/board-components": "3.0.149",
|
|
4533
|
+
"@cloudscape-design/components": "3.0.1204",
|
|
4534
4534
|
"@cloudscape-design/global-styles": "1.0.50",
|
|
4535
|
-
"@tanstack/react-router": "1.
|
|
4535
|
+
"@tanstack/react-router": "1.160.2",
|
|
4536
4536
|
"aws-cdk-lib": "2.238.0",
|
|
4537
|
-
"constructs": "10.
|
|
4537
|
+
"constructs": "10.5.0",
|
|
4538
4538
|
"react": "19.2.4",
|
|
4539
4539
|
"react-dom": "19.2.4",
|
|
4540
4540
|
"tailwindcss": "4.1.18",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StageConfig, StagesConfig } from './stages.types.js';
|
|
2
|
+
import stagesConfig from './stages.config.js';
|
|
3
|
+
|
|
4
|
+
// Widen the narrow `as const` type to StagesConfig for dynamic key access
|
|
5
|
+
const config: StagesConfig = stagesConfig;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolves stage config for a given project and stage name.
|
|
9
|
+
* Project-specific fields take priority over shared ones.
|
|
10
|
+
*
|
|
11
|
+
* @param projectPath - Project path relative to workspace root (e.g., 'packages/infra')
|
|
12
|
+
* @param stageName - CDK stage name (e.g., 'my-app-dev')
|
|
13
|
+
* @returns Merged StageConfig or undefined if no config exists for this stage
|
|
14
|
+
*/
|
|
15
|
+
export function resolveStage(
|
|
16
|
+
projectPath: string,
|
|
17
|
+
stageName: string,
|
|
18
|
+
): StageConfig | undefined {
|
|
19
|
+
const shared = config.shared?.stages?.[stageName];
|
|
20
|
+
const project = config.projects?.[projectPath]?.stages?.[stageName];
|
|
21
|
+
if (!shared && !project) return undefined;
|
|
22
|
+
return { ...shared, ...project } as StageConfig;
|
|
23
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage configuration for CDK deployments.
|
|
3
|
+
*
|
|
4
|
+
* This file maps CDK stage names to their deployment settings. When you run
|
|
5
|
+
* `<%= pkgMgrRunNx %> run <project>:deploy <stage-name>/*`, the infra-deploy script
|
|
6
|
+
* automatically resolves and applies the correct credentials.
|
|
7
|
+
*
|
|
8
|
+
* Project keys are the project path relative to the workspace root
|
|
9
|
+
* (e.g., 'packages/infra').
|
|
10
|
+
*
|
|
11
|
+
* Stage names must match the CDK stage identifiers defined in your main.ts —
|
|
12
|
+
* the first argument to `new ApplicationStage(app, '<stage-name>', ...)`.
|
|
13
|
+
* For example, if main.ts has `new ApplicationStage(app, 'my-app-dev', ...)`
|
|
14
|
+
* then the stage name here is 'my-app-dev'.
|
|
15
|
+
*
|
|
16
|
+
* We recommend committing this file so the team shares a single source of truth.
|
|
17
|
+
* If it contains personal profile names, you can add it to .gitignore instead.
|
|
18
|
+
*/
|
|
19
|
+
import type { StagesConfig } from './stages.types.js';
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
projects: {
|
|
23
|
+
// Example: map stages for a specific infra project
|
|
24
|
+
// 'packages/infra': {
|
|
25
|
+
// stages: {
|
|
26
|
+
// 'my-app-dev': {
|
|
27
|
+
// credentials: { type: 'profile', profile: 'dev-account' },
|
|
28
|
+
// region: 'us-east-1',
|
|
29
|
+
// // account is optional — if omitted, CDK infers from the profile
|
|
30
|
+
// },
|
|
31
|
+
// 'my-app-prod': {
|
|
32
|
+
// credentials: { type: 'assumeRole', assumeRole: 'arn:aws:iam::123456789012:role/DeployRole' },
|
|
33
|
+
// region: 'us-west-2',
|
|
34
|
+
// account: '123456789012',
|
|
35
|
+
// },
|
|
36
|
+
// },
|
|
37
|
+
// },
|
|
38
|
+
},
|
|
39
|
+
shared: {
|
|
40
|
+
stages: {
|
|
41
|
+
// Example: shared sandbox stage available to all projects
|
|
42
|
+
// 'sandbox': {
|
|
43
|
+
// credentials: { type: 'profile', profile: 'sandbox-profile' },
|
|
44
|
+
// region: 'us-east-1',
|
|
45
|
+
// },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
} as const satisfies StagesConfig;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for stage and project configuration.
|
|
3
|
+
*
|
|
4
|
+
* These types are used by both stages.config.ts and the infra-deploy/
|
|
5
|
+
* infra-destroy scripts. They live in a shared package so any
|
|
6
|
+
* project in the workspace can import them.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Use an AWS CLI profile from ~/.aws/config */
|
|
10
|
+
export type ProfileCredentials = {
|
|
11
|
+
type: 'profile';
|
|
12
|
+
/** AWS CLI profile name */
|
|
13
|
+
profile: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Assume an IAM role via STS, optionally using a profile as the source credentials */
|
|
17
|
+
export type AssumeRoleCredentials = {
|
|
18
|
+
type: 'assumeRole';
|
|
19
|
+
/** IAM Role ARN to assume */
|
|
20
|
+
assumeRole: string;
|
|
21
|
+
/** Optional: AWS CLI profile to use as source credentials for the AssumeRole call */
|
|
22
|
+
profile?: string;
|
|
23
|
+
/** Optional: External ID required by the role's trust policy */
|
|
24
|
+
externalId?: string;
|
|
25
|
+
/** Optional: Session duration in seconds (default: 3600). Increase for long deployments. */
|
|
26
|
+
sessionDuration?: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Credentials for deploying to a specific CDK stage.
|
|
31
|
+
* The `type` field determines which credential strategy is used.
|
|
32
|
+
*/
|
|
33
|
+
export type StageCredentials = ProfileCredentials | AssumeRoleCredentials;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for a single CDK stage.
|
|
37
|
+
* Includes credentials, region, and optionally account.
|
|
38
|
+
*/
|
|
39
|
+
export type StageConfig = {
|
|
40
|
+
/** How to authenticate when deploying this stage */
|
|
41
|
+
credentials: StageCredentials;
|
|
42
|
+
/** AWS region for this stage (e.g., 'us-east-1') */
|
|
43
|
+
region: string;
|
|
44
|
+
/** AWS account ID. If omitted, CDK infers it from the active credentials. */
|
|
45
|
+
account?: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Configuration for a single infrastructure project.
|
|
50
|
+
* The key in the parent map is the project path relative to workspace root
|
|
51
|
+
* (e.g., 'packages/infra').
|
|
52
|
+
*/
|
|
53
|
+
export type ProjectConfig = {
|
|
54
|
+
/** Map of CDK stage names to their configuration */
|
|
55
|
+
stages: { [stageName: string]: StageConfig };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Top-level configuration mapping projects and stages to their settings. */
|
|
59
|
+
export type StagesConfig = {
|
|
60
|
+
/** Project-specific config. Key is the project path relative to workspace root. */
|
|
61
|
+
projects?: { [projectPath: string]: ProjectConfig };
|
|
62
|
+
/** Shared stage config available to all projects. */
|
|
63
|
+
shared?: {
|
|
64
|
+
stages: { [stageName: string]: StageConfig };
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Scripts (infra-deploy, infra-destroy) are the public interface of this package.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the CDK command as an array of arguments for spawnSync.
|
|
3
|
+
*
|
|
4
|
+
* Defaults to --require-approval=never (standard for local dev deploys).
|
|
5
|
+
* If the user explicitly passes --require-approval with any value, we
|
|
6
|
+
* respect their choice and don't add the default.
|
|
7
|
+
*/
|
|
8
|
+
export function buildCdkCommand(
|
|
9
|
+
action: string,
|
|
10
|
+
remainingArgs: string[],
|
|
11
|
+
): string[] {
|
|
12
|
+
const hasRequireApproval = remainingArgs.some(
|
|
13
|
+
(a) => a === '--require-approval' || a.startsWith('--require-approval='),
|
|
14
|
+
);
|
|
15
|
+
return hasRequireApproval
|
|
16
|
+
? ['cdk', action, ...remainingArgs]
|
|
17
|
+
: ['cdk', action, '--require-approval=never', ...remainingArgs];
|
|
18
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
StageCredentials,
|
|
3
|
+
StagesConfig,
|
|
4
|
+
} from '<%= scopeAlias %>common-infra-config';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Looks up credentials for a given project + stage combination.
|
|
8
|
+
*
|
|
9
|
+
* Lookup order:
|
|
10
|
+
* 1. Project-specific: config.projects[projectPath].stages[stageName].credentials
|
|
11
|
+
* 2. Shared: config.shared.stages[stageName].credentials
|
|
12
|
+
* 3. No match: returns undefined — caller falls back to env vars
|
|
13
|
+
*/
|
|
14
|
+
export function lookupCredentials(
|
|
15
|
+
config: StagesConfig | undefined,
|
|
16
|
+
projectPath: string,
|
|
17
|
+
stageName: string,
|
|
18
|
+
): { credentials: StageCredentials | undefined; source: string } {
|
|
19
|
+
const projectCreds =
|
|
20
|
+
config?.projects?.[projectPath]?.stages?.[stageName]?.credentials;
|
|
21
|
+
if (projectCreds) {
|
|
22
|
+
return { credentials: projectCreds, source: 'project-specific' };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const sharedCreds = config?.shared?.stages?.[stageName]?.credentials;
|
|
26
|
+
if (sharedCreds) {
|
|
27
|
+
return { credentials: sharedCreds, source: 'shared' };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return { credentials: undefined, source: 'environment fallback' };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Builds a child process environment with the resolved credentials overlaid.
|
|
35
|
+
* Never modifies process.env — returns a new object.
|
|
36
|
+
*/
|
|
37
|
+
export async function buildChildEnv(
|
|
38
|
+
credentials: StageCredentials,
|
|
39
|
+
projectPath: string,
|
|
40
|
+
): Promise<Record<string, string | undefined>> {
|
|
41
|
+
const env = { ...process.env };
|
|
42
|
+
|
|
43
|
+
switch (credentials.type) {
|
|
44
|
+
case 'profile': {
|
|
45
|
+
env.AWS_PROFILE = credentials.profile;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'assumeRole': {
|
|
49
|
+
let STSClient: typeof import('@aws-sdk/client-sts').STSClient;
|
|
50
|
+
let AssumeRoleCommand: typeof import('@aws-sdk/client-sts').AssumeRoleCommand;
|
|
51
|
+
try {
|
|
52
|
+
({ STSClient, AssumeRoleCommand } =
|
|
53
|
+
await import('@aws-sdk/client-sts'));
|
|
54
|
+
} catch {
|
|
55
|
+
console.error(
|
|
56
|
+
'[infra-deploy] Error: @aws-sdk/client-sts is required for assumeRole credentials but is not installed.',
|
|
57
|
+
);
|
|
58
|
+
console.error('[infra-deploy] Please install @aws-sdk/client-sts');
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// If a source profile is specified, configure the STS client to use it
|
|
63
|
+
const stsClientOptions: Record<string, unknown> = {};
|
|
64
|
+
if (credentials.profile) {
|
|
65
|
+
const { fromIni } = await import('@aws-sdk/credential-providers');
|
|
66
|
+
stsClientOptions.credentials = fromIni({
|
|
67
|
+
profile: credentials.profile,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const response = await new STSClient(stsClientOptions).send(
|
|
72
|
+
new AssumeRoleCommand({
|
|
73
|
+
RoleArn: credentials.assumeRole,
|
|
74
|
+
RoleSessionName: `infra-deploy-${projectPath.replace(/\//g, '-')}`,
|
|
75
|
+
...(credentials.externalId
|
|
76
|
+
? { ExternalId: credentials.externalId }
|
|
77
|
+
: {}),
|
|
78
|
+
...(credentials.sessionDuration
|
|
79
|
+
? { DurationSeconds: credentials.sessionDuration }
|
|
80
|
+
: {}),
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
env.AWS_ACCESS_KEY_ID = response.Credentials?.AccessKeyId;
|
|
85
|
+
env.AWS_SECRET_ACCESS_KEY = response.Credentials?.SecretAccessKey;
|
|
86
|
+
env.AWS_SESSION_TOKEN = response.Credentials?.SessionToken;
|
|
87
|
+
delete env.AWS_PROFILE;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return env;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Human-readable description of credentials for logging */
|
|
96
|
+
export function describeCredentials(creds: StageCredentials): string {
|
|
97
|
+
return creds.type === 'profile'
|
|
98
|
+
? `profile '${creds.profile}'`
|
|
99
|
+
: `role '${creds.assumeRole}'`;
|
|
100
|
+
}
|