@aws/nx-plugin 1.0.0-rc.32 → 1.0.0-rc.33

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.
Files changed (188) hide show
  1. package/LICENSE-THIRD-PARTY +72 -70
  2. package/package.json +5 -5
  3. package/src/infra/app/__snapshots__/generator.spec.ts.snap +15 -15
  4. package/src/infra/app/files/app/src/main.ts.template +1 -1
  5. package/src/infra/app/files/app/src/stages/application-stage.ts.template +1 -1
  6. package/src/infra/app/generator.js +3 -1
  7. package/src/infra/app/generator.js.map +1 -1
  8. package/src/open-api/ts-client/files/client.gen.ts.template +1 -1
  9. package/src/open-api/ts-client/generator.js +5 -1
  10. package/src/open-api/ts-client/generator.js.map +1 -1
  11. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +2 -2
  12. package/src/open-api/ts-hooks/generator.js +5 -1
  13. package/src/open-api/ts-hooks/generator.js.map +1 -1
  14. package/src/preset/__snapshots__/generator.spec.ts.snap +1 -1
  15. package/src/preset/generator.d.ts +1 -1
  16. package/src/preset/generator.js +5 -2
  17. package/src/preset/generator.js.map +1 -1
  18. package/src/preset/schema.d.js.map +1 -1
  19. package/src/preset/schema.d.ts +2 -0
  20. package/src/preset/schema.json +6 -0
  21. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +7 -7
  22. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
  23. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +89 -3
  24. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  25. package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
  26. package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  27. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +91 -5
  28. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +7 -7
  29. package/src/smithy/ts/api/files/handler.ts.template +2 -2
  30. package/src/smithy/ts/api/files/local-server.ts.template +2 -2
  31. package/src/smithy/ts/api/files/operations/echo.ts.template +2 -2
  32. package/src/smithy/ts/api/files/service.ts.template +3 -3
  33. package/src/smithy/ts/api/generator.js +3 -1
  34. package/src/smithy/ts/api/generator.js.map +1 -1
  35. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
  36. package/src/trpc/backend/files/src/client/index.ts.template +1 -1
  37. package/src/trpc/backend/files/src/handler.ts.template +1 -1
  38. package/src/trpc/backend/files/src/index.ts.template +5 -5
  39. package/src/trpc/backend/files/src/init.ts.template +1 -1
  40. package/src/trpc/backend/files/src/local-server.ts.template +1 -1
  41. package/src/trpc/backend/files/src/middleware/index.ts.template +7 -7
  42. package/src/trpc/backend/files/src/procedures/echo.ts.template +2 -2
  43. package/src/trpc/backend/files/src/router.ts.template +2 -2
  44. package/src/trpc/backend/files/src/schema/index.ts.template +1 -1
  45. package/src/trpc/backend/generator.js +3 -1
  46. package/src/trpc/backend/generator.js.map +1 -1
  47. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +89 -3
  48. package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +2 -2
  49. package/src/ts/agent/a2a-connection/generator.js +3 -1
  50. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  51. package/src/ts/agent/files/a2a/index.ts.template +1 -1
  52. package/src/ts/agent/files/ag-ui/index.ts.template +1 -1
  53. package/src/ts/agent/files/http/client.ts.template +2 -2
  54. package/src/ts/agent/files/http/index.ts.template +2 -2
  55. package/src/ts/agent/files/http/router.ts.template +3 -3
  56. package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +2 -2
  57. package/src/ts/agent/gateway-connection/generator.js +3 -1
  58. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  59. package/src/ts/agent/generator.js +5 -2
  60. package/src/ts/agent/generator.js.map +1 -1
  61. package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +2 -2
  62. package/src/ts/agent/mcp-connection/generator.js +3 -1
  63. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  64. package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +3 -2
  65. package/src/ts/astro-docs/generator.js +2 -0
  66. package/src/ts/astro-docs/generator.js.map +1 -1
  67. package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  68. package/src/ts/dynamodb/files/src/client.ts.template +5 -2
  69. package/src/ts/dynamodb/files/src/entities/example.ts.template +1 -1
  70. package/src/ts/dynamodb/files/src/entities/index.ts.template +1 -1
  71. package/src/ts/dynamodb/files/src/index.ts.template +2 -2
  72. package/src/ts/dynamodb/generator.js +3 -1
  73. package/src/ts/dynamodb/generator.js.map +1 -1
  74. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  75. package/src/ts/lib/generator.js +7 -1
  76. package/src/ts/lib/generator.js.map +1 -1
  77. package/src/ts/lib/ts-project-utils.js +19 -4
  78. package/src/ts/lib/ts-project-utils.js.map +1 -1
  79. package/src/ts/lib/types.d.ts +6 -0
  80. package/src/ts/lib/types.js.map +1 -1
  81. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +94 -8
  82. package/src/ts/mcp-server/generator.js +3 -2
  83. package/src/ts/mcp-server/generator.js.map +1 -1
  84. package/src/ts/nx-generator/files/local/generator.ts.template +2 -2
  85. package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +2 -2
  86. package/src/ts/nx-generator/generator.js +5 -2
  87. package/src/ts/nx-generator/generator.js.map +1 -1
  88. package/src/ts/nx-plugin/files/mcp-server/server.ts.template +5 -5
  89. package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +2 -2
  90. package/src/ts/nx-plugin/files/mcp-server/tools/general-guidance.ts.template +1 -1
  91. package/src/ts/nx-plugin/files/mcp-server/tools/generator-guide.ts.template +2 -2
  92. package/src/ts/nx-plugin/files/mcp-server/tools/list-generators.ts.template +2 -2
  93. package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +3 -3
  94. package/src/ts/nx-plugin/generator.js +3 -1
  95. package/src/ts/nx-plugin/generator.js.map +1 -1
  96. package/src/ts/nx-plugin/utils.js +7 -4
  97. package/src/ts/nx-plugin/utils.js.map +1 -1
  98. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -4
  99. package/src/ts/rdb/files/src/create-db-user-handler.ts.template +2 -2
  100. package/src/ts/rdb/files/src/index.ts.template +1 -1
  101. package/src/ts/rdb/files/src/migration-handler.ts.template +1 -1
  102. package/src/ts/rdb/files/src/prisma.ts.template +7 -4
  103. package/src/ts/rdb/generator.js +3 -1
  104. package/src/ts/rdb/generator.js.map +1 -1
  105. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +35 -35
  106. package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
  107. package/src/utils/agent-chat/agent-chat.js +3 -1
  108. package/src/utils/agent-chat/agent-chat.js.map +1 -1
  109. package/src/utils/agent-chat/files/a2a/chat.ts.template +1 -1
  110. package/src/utils/agent-chat/files/ag-ui/chat.ts.template +1 -1
  111. package/src/utils/agent-chat/files/http-py/chat.ts.template +2 -2
  112. package/src/utils/agent-chat/files/http-ts/chat.ts.template +1 -1
  113. package/src/utils/agent-connection/agent-connection.js +4 -1
  114. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  115. package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +2 -2
  116. package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +1 -1
  117. package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +2 -2
  118. package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +2 -2
  119. package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +1 -1
  120. package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +1 -1
  121. package/src/utils/agent-connection/files/core-strands/base/with-session-id-strands.ts.template +1 -1
  122. package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +1 -1
  123. package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +1 -1
  124. package/src/utils/agent-core-constructs/agent-core-constructs.js +10 -3
  125. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  126. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +3 -3
  127. package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +4 -4
  128. package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +1 -1
  129. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +27 -0
  130. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +60 -1
  131. package/src/utils/api-constructs/api-constructs.js +8 -2
  132. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  133. package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +8 -8
  134. package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +8 -8
  135. package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +3 -3
  136. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template +32 -20
  137. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account.ts.template +1 -1
  138. package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +4 -4
  139. package/src/utils/api-constructs/files/cdk/core/api/trpc/trpc-utils.ts.template +1 -1
  140. package/src/utils/ast.js +16 -0
  141. package/src/utils/ast.js.map +1 -1
  142. package/src/utils/commands.d.ts +1 -1
  143. package/src/utils/commands.js +4 -1
  144. package/src/utils/commands.js.map +1 -1
  145. package/src/utils/dynamodb-constructs/dynamodb-constructs.js +9 -2
  146. package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
  147. package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +3 -3
  148. package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +1 -1
  149. package/src/utils/files/common/constructs/src/core/index.ts.template +4 -4
  150. package/src/utils/files/common/constructs/src/index.ts.template +2 -2
  151. package/src/utils/files/common/infra-config/src/index.ts.template +3 -3
  152. package/src/utils/files/common/infra-config/src/resolve-stage.ts.template +2 -2
  153. package/src/utils/files/common/infra-config/src/stages.config.ts.template +1 -1
  154. package/src/utils/files/common/scripts/src/infra/infra-deploy.ts.template +1 -1
  155. package/src/utils/files/common/scripts/src/infra/infra-destroy.ts.template +1 -1
  156. package/src/utils/files/common/scripts/src/infra/stage-credentials/run.ts.template +3 -3
  157. package/src/utils/files/common/shadcn/src/index.ts.template +2 -2
  158. package/src/utils/function-constructs/files/cdk/app/lambda-functions/__nameKebabCase__.ts.template +1 -1
  159. package/src/utils/function-constructs/function-constructs.js +3 -1
  160. package/src/utils/function-constructs/function-constructs.js.map +1 -1
  161. package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +2 -2
  162. package/src/utils/identity-constructs/identity-constructs.js +5 -1
  163. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  164. package/src/utils/module-format.d.ts +28 -0
  165. package/src/utils/module-format.js +28 -0
  166. package/src/utils/module-format.js.map +1 -0
  167. package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +5 -5
  168. package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +1 -1
  169. package/src/utils/rdb-constructs/rdb-constructs.js +9 -2
  170. package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
  171. package/src/utils/shared-constructs.js +3 -1
  172. package/src/utils/shared-constructs.js.map +1 -1
  173. package/src/utils/shared-infra-config.js +3 -1
  174. package/src/utils/shared-infra-config.js.map +1 -1
  175. package/src/utils/shared-infra-scripts.js +3 -1
  176. package/src/utils/shared-infra-scripts.js.map +1 -1
  177. package/src/utils/shared-shadcn.js +3 -1
  178. package/src/utils/shared-shadcn.js.map +1 -1
  179. package/src/utils/test.d.ts +2 -0
  180. package/src/utils/test.js +7 -1
  181. package/src/utils/test.js.map +1 -1
  182. package/src/utils/versions.d.ts +58 -58
  183. package/src/utils/versions.js +56 -56
  184. package/src/utils/versions.js.map +1 -1
  185. package/src/utils/website-constructs/files/cdk/app/static-websites/__websiteNameKebabCase__.ts.template +2 -2
  186. package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +2 -2
  187. package/src/utils/website-constructs/website-constructs.js +9 -2
  188. package/src/utils/website-constructs/website-constructs.js.map +1 -1
@@ -119,8 +119,9 @@ const setUpGitSecrets = (tree)=>{
119
119
  'husky'
120
120
  ]));
121
121
  };
122
- export const presetGenerator = async (tree, { iac, gitSecrets, mcp, containers, preferInstallDependencies })=>{
122
+ export const presetGenerator = async (tree, { iac, gitSecrets, mcp, containers, module, preferInstallDependencies })=>{
123
123
  const resolvedContainers = !containers || containers === 'infer' ? inferContainers() : containers;
124
+ const esm = (module ?? 'esm') === 'esm';
124
125
  if (isAmazonian() && !process.env.VITEST && !process.env.CI && process.env.NX_DRY_RUN !== 'true' && process.env.NX_INTERACTIVE !== 'false') {
125
126
  const { engagementId } = await enquirer.prompt([
126
127
  {
@@ -178,7 +179,9 @@ export const presetGenerator = async (tree, { iac, gitSecrets, mcp, containers,
178
179
  });
179
180
  updateJson(tree, 'package.json', (packageJson)=>({
180
181
  ...packageJson,
181
- type: 'module',
182
+ // Written explicitly so later generators can infer the workspace's module
183
+ // format from the root `type`.
184
+ type: esm ? 'module' : 'commonjs',
182
185
  scripts: {
183
186
  ...packageJson.scripts,
184
187
  dev: 'nx run-many --target dev',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/preset/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readNxJson,\n type Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { initGenerator } from '@nx/js';\nimport { execSync } from 'child_process';\nimport enquirer from 'enquirer';\nimport { readFileSync } from 'fs';\nimport yaml from 'js-yaml';\nimport { readModulePackageJson } from 'nx/src/utils/package-json';\nimport GeneratorsJson from '../../generators.json' with { type: 'json' };\nimport { SYNC_GENERATOR_NAME as TS_SYNC_GENERATOR_NAME } from '../ts/sync/generator';\nimport {\n ensureAwsNxPluginConfig,\n updateAwsNxPluginConfig,\n} from '../utils/config/utils';\nimport { inferContainers } from '../utils/containers';\nimport { DEFAULT_BIOME_CONFIG, formatFilesInSubtree } from '../utils/format';\nimport { installDependencies } from '../utils/install';\nimport { configureMcpServers } from '../utils/mcp';\nimport { addGeneratorMetricsIfApplicable } from '../utils/metrics';\nimport { getNpmScope } from '../utils/npm-scope';\nimport { getGeneratorInfo, type NxGeneratorInfo } from '../utils/nx';\nimport { getPackageManagerDisplayCommands } from '../utils/pkg-manager';\nimport { withVersions } from '../utils/versions';\nimport type { PresetGeneratorSchema } from './schema';\n\nconst WORKSPACES = ['packages/*'];\nconst NX_TYPESCRIPT_SYNC_GENERATOR = '@nx/js:typescript-sync';\n\n// Built dependencies whose install scripts the generated workspace trusts.\n// `onlyBuiltDependencies` is the pnpm 10 key (silently ignored by pnpm 11);\n// pnpm 11 reads `allowBuilds` instead. Any dep NOT in this allowlist will\n// have its install scripts skipped with a warning — matching pnpm 10's\n// default behaviour. The user can opt-in later via `pnpm approve-builds`.\nconst PNPM_BUILT_DEPENDENCIES = ['@swc/core', 'esbuild', 'nx', 'sharp'];\n\nexport const PRESET_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nconst setUpWorkspaces = (tree: Tree) => {\n if (detectPackageManager() === 'pnpm') {\n tree.write(\n 'pnpm-workspace.yaml',\n yaml.dump(\n {\n packages: WORKSPACES,\n allowBuilds: Object.fromEntries(\n PNPM_BUILT_DEPENDENCIES.map((dep) => [dep, true]),\n ),\n onlyBuiltDependencies: PNPM_BUILT_DEPENDENCIES,\n },\n { quotingType: \"'\" },\n ),\n );\n } else {\n updateJson(tree, 'package.json', (json) => {\n json.workspaces = WORKSPACES;\n return json;\n });\n }\n};\n\n/**\n * Determines if the current user is an Amazon employee based on their git configuration.\n *\n * This function checks the git user email configuration to identify Amazon employees\n * by looking for email addresses with Amazon domains (e.g., @amazon.com, @amazon.co.uk).\n *\n * @returns {boolean} True if the user's git email has an Amazon domain, false otherwise\n *\n * @example\n * // Returns true for Amazon employee emails\n * // git config user.email = \"john.doe@amazon.com\"\n * isAmazonian(); // true\n *\n * @example\n * // Returns false for non-Amazon emails\n * // git config user.email = \"user@example.com\"\n * isAmazonian(); // false\n *\n * @example\n * // Returns false when git config is not available or throws an error\n * isAmazonian(); // false\n */\nexport function isAmazonian(): boolean {\n try {\n // Execute git command to retrieve the user's configured email address\n const gitEmail = execSync('git config user.email', {\n encoding: 'utf8',\n }).trim();\n\n // Return false if no email is configured\n if (!gitEmail) {\n return false;\n }\n\n // Split email address to extract domain part\n const emailParts = gitEmail.split('@');\n if (emailParts.length < 2) {\n return false;\n }\n\n // Extract domain and normalize to lowercase for comparison\n const domain = emailParts[1].toLowerCase();\n\n // Check if domain starts with 'amazon.' (covers amazon.com, amazon.co.uk, etc.)\n return domain.startsWith('amazon.');\n } catch (error) {\n // Return false if git command fails or any other error occurs\n // This handles cases where git is not installed or configured\n return false;\n }\n}\n\nconst setUpGitSecrets = (tree: Tree) => {\n const gitSecretsDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'git-secrets-dir',\n );\n const huskyDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'husky-dir',\n );\n\n tree.write(\n '.git-secrets/git-secrets',\n readFileSync(joinPathFragments(gitSecretsDir, 'git-secrets'), 'utf-8'),\n );\n tree.write(\n '.husky/pre-commit',\n readFileSync(joinPathFragments(huskyDir, 'pre-commit'), 'utf-8'),\n );\n tree.write('.gitallowed', '\\\\.git-secrets/git-secrets:\\n');\n\n updateJson(tree, 'package.json', (json) => ({\n ...json,\n scripts: {\n ...json.scripts,\n prepare: 'husky',\n },\n }));\n\n addDependenciesToPackageJson(tree, {}, withVersions(['husky']));\n};\n\nexport const presetGenerator = async (\n tree: Tree,\n {\n iac,\n gitSecrets,\n mcp,\n containers,\n preferInstallDependencies,\n }: PresetGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const resolvedContainers =\n !containers || containers === 'infer' ? inferContainers() : containers;\n if (\n isAmazonian() &&\n !process.env.VITEST &&\n !process.env.CI &&\n process.env.NX_DRY_RUN !== 'true' &&\n process.env.NX_INTERACTIVE !== 'false'\n ) {\n const { engagementId } = await enquirer.prompt<{ engagementId?: string }>([\n {\n name: 'engagementId',\n message: 'Please enter your engagementId (if known)',\n type: 'input',\n initial: 'None',\n },\n ]);\n\n if (engagementId != 'None') {\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, { tags: [engagementId] });\n }\n }\n\n // Write IaC provider and container engine to plugin config\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, {\n iac: { provider: iac },\n containers: { engine: resolvedContainers },\n });\n\n await initGenerator(tree, {\n formatter: 'none',\n addTsPlugin: true,\n });\n\n tree.delete('apps/.gitkeep');\n tree.delete('libs/.gitkeep');\n tree.write('packages/.gitkeep', '');\n\n setUpWorkspaces(tree);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n analytics: false,\n targetDefaults: {\n ...nxJson.targetDefaults,\n compile: {\n ...nxJson.targetDefaults?.compile,\n syncGenerators: [\n ...(nxJson.targetDefaults?.compile?.syncGenerators ?? []).filter(\n (g) =>\n ![TS_SYNC_GENERATOR_NAME, NX_TYPESCRIPT_SYNC_GENERATOR].includes(\n g,\n ),\n ),\n NX_TYPESCRIPT_SYNC_GENERATOR,\n TS_SYNC_GENERATOR_NAME,\n ],\n },\n },\n });\n\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n type: 'module',\n scripts: {\n ...packageJson.scripts,\n dev: 'nx run-many --target dev',\n build: 'nx run-many --target build',\n lint: 'nx run-many --target lint --configuration=fix',\n test: 'nx run-many --target test --all',\n 'build:skip-lint': 'nx run-many --target build --configuration=skip-lint',\n 'build:all': 'nx run-many --target build --all',\n 'affected:all': 'nx affected --target build',\n },\n }));\n\n addDependenciesToPackageJson(\n tree,\n {},\n {\n '@nx/workspace': readModulePackageJson('@nx/js').packageJson.version,\n ...withVersions(['typescript', '@biomejs/biome']),\n },\n );\n\n // Write biome.json for formatting and linting\n if (!tree.exists('biome.json')) {\n tree.write('biome.json', JSON.stringify(DEFAULT_BIOME_CONFIG, null, 2));\n }\n\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, 'files'),\n '.',\n {\n projectName: getNpmScope(tree),\n generators: Object.entries(GeneratorsJson.generators)\n .filter(([_, v]) => !v['hidden'])\n .map(([k, v]) => ({ name: k, description: v.description })),\n ...(() => {\n const cmds = getPackageManagerDisplayCommands();\n return {\n pkgMgrCmd: cmds.exec,\n buildCmd: `${cmds.run} build`,\n lintCmd: `${cmds.run} lint`,\n };\n })(),\n },\n {\n overwriteStrategy: OverwriteStrategy.Overwrite,\n },\n );\n\n if (gitSecrets !== false) {\n setUpGitSecrets(tree);\n }\n\n if (mcp !== false) {\n configureMcpServers(tree);\n }\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default presetGenerator;\n"],"names":["addDependenciesToPackageJson","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readNxJson","updateJson","updateNxJson","initGenerator","execSync","enquirer","readFileSync","yaml","readModulePackageJson","GeneratorsJson","type","SYNC_GENERATOR_NAME","TS_SYNC_GENERATOR_NAME","ensureAwsNxPluginConfig","updateAwsNxPluginConfig","inferContainers","DEFAULT_BIOME_CONFIG","formatFilesInSubtree","installDependencies","configureMcpServers","getNpmScope","getGeneratorInfo","getPackageManagerDisplayCommands","withVersions","WORKSPACES","NX_TYPESCRIPT_SYNC_GENERATOR","PNPM_BUILT_DEPENDENCIES","PRESET_GENERATOR_INFO","filename","setUpWorkspaces","tree","write","dump","packages","allowBuilds","Object","fromEntries","map","dep","onlyBuiltDependencies","quotingType","json","workspaces","isAmazonian","gitEmail","encoding","trim","emailParts","split","length","domain","toLowerCase","startsWith","error","setUpGitSecrets","gitSecretsDir","dirname","huskyDir","scripts","prepare","presetGenerator","iac","gitSecrets","mcp","containers","preferInstallDependencies","resolvedContainers","process","env","VITEST","CI","NX_DRY_RUN","NX_INTERACTIVE","engagementId","prompt","name","message","initial","tags","provider","engine","formatter","addTsPlugin","delete","nxJson","analytics","targetDefaults","compile","syncGenerators","filter","g","includes","packageJson","dev","build","lint","test","version","exists","JSON","stringify","projectName","generators","entries","_","v","k","description","cmds","pkgMgrCmd","exec","buildCmd","run","lintCmd","overwriteStrategy","Overwrite","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EAEVC,UAAU,EACVC,YAAY,QACP,aAAa;AACpB,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,cAAc,WAAW;AAChC,SAASC,YAAY,QAAQ,KAAK;AAClC,OAAOC,UAAU,UAAU;AAC3B,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,OAAOC,oBAAoB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACzE,SAASC,uBAAuBC,sBAAsB,QAAQ,0BAAuB;AACrF,SACEC,uBAAuB,EACvBC,uBAAuB,QA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,eAAe;QAC9BpE,KAAKC,KAAK,CAAC,cAAcoE,KAAKC,SAAS,CAACpF,sBAAsB,MAAM;IACtE;IAEAnB,cACEiC,MACAhC,kBAAkB,YAAY0D,OAAO,EAAE,UACvC,KACA;QACE6C,aAAajF,YAAYU;QACzBwE,YAAYnE,OAAOoE,OAAO,CAAC9F,eAAe6F,UAAU,EACjDb,MAAM,CAAC,CAAC,CAACe,GAAGC,EAAE,GAAK,CAACA,CAAC,CAAC,SAAS,EAC/BpE,GAAG,CAAC,CAAC,CAACqE,GAAGD,EAAE,GAAM,CAAA;gBAAE9B,MAAM+B;gBAAGC,aAAaF,EAAEE,WAAW;YAAC,CAAA;QAC1D,GAAG,AAAC,CAAA;YACF,MAAMC,OAAOtF;YACb,OAAO;gBACLuF,WAAWD,KAAKE,IAAI;gBACpBC,UAAU,GAAGH,KAAKI,GAAG,CAAC,MAAM,CAAC;gBAC7BC,SAAS,GAAGL,KAAKI,GAAG,CAAC,KAAK,CAAC;YAC7B;QACF,CAAA,GAAI;IACN,GACA;QACEE,mBAAmBnH,kBAAkBoH,SAAS;IAChD;IAGF,IAAIrD,eAAe,OAAO;QACxBR,gBAAgBxB;IAClB;IAEA,IAAIiC,QAAQ,OAAO;QACjB5C,oBAAoBW;IACtB;IAEA,MAAMb,qBAAqBa;IAC3B,OAAO,IACLZ,oBAAoBY,MAAMmC,2BAA2B;YACnDmD,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAexD,gBAAgB"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/preset/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readNxJson,\n type Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { initGenerator } from '@nx/js';\nimport { execSync } from 'child_process';\nimport enquirer from 'enquirer';\nimport { readFileSync } from 'fs';\nimport yaml from 'js-yaml';\nimport { readModulePackageJson } from 'nx/src/utils/package-json';\nimport GeneratorsJson from '../../generators.json' with { type: 'json' };\nimport { SYNC_GENERATOR_NAME as TS_SYNC_GENERATOR_NAME } from '../ts/sync/generator';\nimport {\n ensureAwsNxPluginConfig,\n updateAwsNxPluginConfig,\n} from '../utils/config/utils';\nimport { inferContainers } from '../utils/containers';\nimport { DEFAULT_BIOME_CONFIG, formatFilesInSubtree } from '../utils/format';\nimport { installDependencies } from '../utils/install';\nimport { configureMcpServers } from '../utils/mcp';\nimport { addGeneratorMetricsIfApplicable } from '../utils/metrics';\nimport { getNpmScope } from '../utils/npm-scope';\nimport { getGeneratorInfo, type NxGeneratorInfo } from '../utils/nx';\nimport { getPackageManagerDisplayCommands } from '../utils/pkg-manager';\nimport { withVersions } from '../utils/versions';\nimport type { PresetGeneratorSchema } from './schema';\n\nconst WORKSPACES = ['packages/*'];\nconst NX_TYPESCRIPT_SYNC_GENERATOR = '@nx/js:typescript-sync';\n\n// Built dependencies whose install scripts the generated workspace trusts.\n// `onlyBuiltDependencies` is the pnpm 10 key (silently ignored by pnpm 11);\n// pnpm 11 reads `allowBuilds` instead. Any dep NOT in this allowlist will\n// have its install scripts skipped with a warning — matching pnpm 10's\n// default behaviour. The user can opt-in later via `pnpm approve-builds`.\nconst PNPM_BUILT_DEPENDENCIES = ['@swc/core', 'esbuild', 'nx', 'sharp'];\n\nexport const PRESET_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nconst setUpWorkspaces = (tree: Tree) => {\n if (detectPackageManager() === 'pnpm') {\n tree.write(\n 'pnpm-workspace.yaml',\n yaml.dump(\n {\n packages: WORKSPACES,\n allowBuilds: Object.fromEntries(\n PNPM_BUILT_DEPENDENCIES.map((dep) => [dep, true]),\n ),\n onlyBuiltDependencies: PNPM_BUILT_DEPENDENCIES,\n },\n { quotingType: \"'\" },\n ),\n );\n } else {\n updateJson(tree, 'package.json', (json) => {\n json.workspaces = WORKSPACES;\n return json;\n });\n }\n};\n\n/**\n * Determines if the current user is an Amazon employee based on their git configuration.\n *\n * This function checks the git user email configuration to identify Amazon employees\n * by looking for email addresses with Amazon domains (e.g., @amazon.com, @amazon.co.uk).\n *\n * @returns {boolean} True if the user's git email has an Amazon domain, false otherwise\n *\n * @example\n * // Returns true for Amazon employee emails\n * // git config user.email = \"john.doe@amazon.com\"\n * isAmazonian(); // true\n *\n * @example\n * // Returns false for non-Amazon emails\n * // git config user.email = \"user@example.com\"\n * isAmazonian(); // false\n *\n * @example\n * // Returns false when git config is not available or throws an error\n * isAmazonian(); // false\n */\nexport function isAmazonian(): boolean {\n try {\n // Execute git command to retrieve the user's configured email address\n const gitEmail = execSync('git config user.email', {\n encoding: 'utf8',\n }).trim();\n\n // Return false if no email is configured\n if (!gitEmail) {\n return false;\n }\n\n // Split email address to extract domain part\n const emailParts = gitEmail.split('@');\n if (emailParts.length < 2) {\n return false;\n }\n\n // Extract domain and normalize to lowercase for comparison\n const domain = emailParts[1].toLowerCase();\n\n // Check if domain starts with 'amazon.' (covers amazon.com, amazon.co.uk, etc.)\n return domain.startsWith('amazon.');\n } catch (error) {\n // Return false if git command fails or any other error occurs\n // This handles cases where git is not installed or configured\n return false;\n }\n}\n\nconst setUpGitSecrets = (tree: Tree) => {\n const gitSecretsDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'git-secrets-dir',\n );\n const huskyDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'husky-dir',\n );\n\n tree.write(\n '.git-secrets/git-secrets',\n readFileSync(joinPathFragments(gitSecretsDir, 'git-secrets'), 'utf-8'),\n );\n tree.write(\n '.husky/pre-commit',\n readFileSync(joinPathFragments(huskyDir, 'pre-commit'), 'utf-8'),\n );\n tree.write('.gitallowed', '\\\\.git-secrets/git-secrets:\\n');\n\n updateJson(tree, 'package.json', (json) => ({\n ...json,\n scripts: {\n ...json.scripts,\n prepare: 'husky',\n },\n }));\n\n addDependenciesToPackageJson(tree, {}, withVersions(['husky']));\n};\n\nexport const presetGenerator = async (\n tree: Tree,\n {\n iac,\n gitSecrets,\n mcp,\n containers,\n module,\n preferInstallDependencies,\n }: PresetGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const resolvedContainers =\n !containers || containers === 'infer' ? inferContainers() : containers;\n const esm = (module ?? 'esm') === 'esm';\n if (\n isAmazonian() &&\n !process.env.VITEST &&\n !process.env.CI &&\n process.env.NX_DRY_RUN !== 'true' &&\n process.env.NX_INTERACTIVE !== 'false'\n ) {\n const { engagementId } = await enquirer.prompt<{ engagementId?: string }>([\n {\n name: 'engagementId',\n message: 'Please enter your engagementId (if known)',\n type: 'input',\n initial: 'None',\n },\n ]);\n\n if (engagementId != 'None') {\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, { tags: [engagementId] });\n }\n }\n\n // Write IaC provider and container engine to plugin config\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, {\n iac: { provider: iac },\n containers: { engine: resolvedContainers },\n });\n\n await initGenerator(tree, {\n formatter: 'none',\n addTsPlugin: true,\n });\n\n tree.delete('apps/.gitkeep');\n tree.delete('libs/.gitkeep');\n tree.write('packages/.gitkeep', '');\n\n setUpWorkspaces(tree);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n analytics: false,\n targetDefaults: {\n ...nxJson.targetDefaults,\n compile: {\n ...nxJson.targetDefaults?.compile,\n syncGenerators: [\n ...(nxJson.targetDefaults?.compile?.syncGenerators ?? []).filter(\n (g) =>\n ![TS_SYNC_GENERATOR_NAME, NX_TYPESCRIPT_SYNC_GENERATOR].includes(\n g,\n ),\n ),\n NX_TYPESCRIPT_SYNC_GENERATOR,\n TS_SYNC_GENERATOR_NAME,\n ],\n },\n },\n });\n\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n // Written explicitly so later generators can infer the workspace's module\n // format from the root `type`.\n type: esm ? 'module' : 'commonjs',\n scripts: {\n ...packageJson.scripts,\n dev: 'nx run-many --target dev',\n build: 'nx run-many --target build',\n lint: 'nx run-many --target lint --configuration=fix',\n test: 'nx run-many --target test --all',\n 'build:skip-lint': 'nx run-many --target build --configuration=skip-lint',\n 'build:all': 'nx run-many --target build --all',\n 'affected:all': 'nx affected --target build',\n },\n }));\n\n addDependenciesToPackageJson(\n tree,\n {},\n {\n '@nx/workspace': readModulePackageJson('@nx/js').packageJson.version,\n ...withVersions(['typescript', '@biomejs/biome']),\n },\n );\n\n // Write biome.json for formatting and linting\n if (!tree.exists('biome.json')) {\n tree.write('biome.json', JSON.stringify(DEFAULT_BIOME_CONFIG, null, 2));\n }\n\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, 'files'),\n '.',\n {\n projectName: getNpmScope(tree),\n generators: Object.entries(GeneratorsJson.generators)\n .filter(([_, v]) => !v['hidden'])\n .map(([k, v]) => ({ name: k, description: v.description })),\n ...(() => {\n const cmds = getPackageManagerDisplayCommands();\n return {\n pkgMgrCmd: cmds.exec,\n buildCmd: `${cmds.run} build`,\n lintCmd: `${cmds.run} lint`,\n };\n })(),\n },\n {\n overwriteStrategy: OverwriteStrategy.Overwrite,\n },\n );\n\n if (gitSecrets !== false) {\n setUpGitSecrets(tree);\n }\n\n if (mcp !== false) {\n configureMcpServers(tree);\n }\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default presetGenerator;\n"],"names":["addDependenciesToPackageJson","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readNxJson","updateJson","updateNxJson","initGenerator","execSync","enquirer","readFileSync","yaml","readModulePackageJson","GeneratorsJson","type","SYNC_GENERATOR_NAME","TS_SYNC_GENERATOR_NAME","ensureAwsNxPluginConfig","updateAwsNxPluginConfig","inferContainers","DEFAULT_BIOME_CONFIG","formatFilesInSubtree","installDependencies","configureMcpServers","getNpmScope","getGeneratorInfo","getPackageManagerDisplayCommands","withVersions","WORKSPACES","NX_TYPESCRIPT_SYNC_GENERATOR","PNPM_BUILT_DEPENDENCIES","PRESET_GENERATOR_INFO","filename","setUpWorkspaces","tree","write","dump","packages","allowBuilds","Object","fromEntries","map","dep","onlyBuiltDependencies","quotingType","json","workspaces","isAmazonian","gitEmail","encoding","trim","emailParts","split","length","domain","toLowerCase","startsWith","error","setUpGitSecrets","gitSecretsDir","dirname","huskyDir","scripts","prepare","presetGenerator","iac","gitSecrets","mcp","containers","module","preferInstallDependencies","resolvedContainers","esm","process","env","VITEST","CI","NX_DRY_RUN","NX_INTERACTIVE","engagementId","prompt","name","message","initial","tags","provider","engine","formatter","addTsPlugin","delete","nxJson","analytics","targetDefaults","compile","syncGenerators","filter","g","includes","packageJson","dev","build","lint","test","version","exists","JSON","stringify","projectName","generators","entries","_","v","k","description","cmds","pkgMgrCmd","exec","buildCmd","run","lintCmd","overwriteStrategy","Overwrite","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EAEVC,UAAU,EACVC,YAAY,QACP,aAAa;AACpB,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,cAAc,WAAW;AAChC,SAASC,YAAY,QAAQ,KAAK;AAClC,OAAOC,UAAU,UAAU;AAC3B,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,OAAOC,oBAAoB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACzE,SAASC,uBAAuBC,sBAAsB,QAAQ,0BAAuB;AACrF,SACEC,uBAAuB,EACvBC,uBAAuB,QAClB,2BAAwB;AAC/B,SAASC,eAAe,QAAQ,yBAAsB;AACtD,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,qBAAkB;AAC7E,SAASC,mBAAmB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AC9BtE,KAAKC,KAAK,CAAC,cAAcsE,KAAKC,SAAS,CAACtF,sBAAsB,MAAM;IACtE;IAEAnB,cACEiC,MACAhC,kBAAkB,YAAY0D,OAAO,EAAE,UACvC,KACA;QACE+C,aAAanF,YAAYU;QACzB0E,YAAYrE,OAAOsE,OAAO,CAAChG,eAAe+F,UAAU,EACjDb,MAAM,CAAC,CAAC,CAACe,GAAGC,EAAE,GAAK,CAACA,CAAC,CAAC,SAAS,EAC/BtE,GAAG,CAAC,CAAC,CAACuE,GAAGD,EAAE,GAAM,CAAA;gBAAE9B,MAAM+B;gBAAGC,aAAaF,EAAEE,WAAW;YAAC,CAAA;QAC1D,GAAG,AAAC,CAAA;YACF,MAAMC,OAAOxF;YACb,OAAO;gBACLyF,WAAWD,KAAKE,IAAI;gBACpBC,UAAU,GAAGH,KAAKI,GAAG,CAAC,MAAM,CAAC;gBAC7BC,SAAS,GAAGL,KAAKI,GAAG,CAAC,KAAK,CAAC;YAC7B;QACF,CAAA,GAAI;IACN,GACA;QACEE,mBAAmBrH,kBAAkBsH,SAAS;IAChD;IAGF,IAAIvD,eAAe,OAAO;QACxBR,gBAAgBxB;IAClB;IAEA,IAAIiC,QAAQ,OAAO;QACjB5C,oBAAoBW;IACtB;IAEA,MAAMb,qBAAqBa;IAC3B,OAAO,IACLZ,oBAAoBY,MAAMoC,2BAA2B;YACnDoD,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe1D,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/preset/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Containers } from '../utils/containers';\nimport { Iac } from '../utils/iac';\n\nexport type PresetContainersOption = Containers | 'infer';\n\nexport interface PresetGeneratorSchema {\n readonly iac: Iac;\n readonly gitSecrets?: boolean;\n readonly mcp?: boolean;\n readonly containers?: PresetContainersOption;\n readonly preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAOD,WAMC"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/preset/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Containers } from '../utils/containers';\nimport { Iac } from '../utils/iac';\nimport type { ModuleFormat } from '../utils/module-format';\n\nexport type PresetContainersOption = Containers | 'infer';\n\nexport interface PresetGeneratorSchema {\n readonly iac: Iac;\n readonly gitSecrets?: boolean;\n readonly mcp?: boolean;\n readonly containers?: PresetContainersOption;\n readonly module?: ModuleFormat;\n readonly preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAQD,WAOC"}
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { Containers } from '../utils/containers';
7
7
  import { Iac } from '../utils/iac';
8
+ import type { ModuleFormat } from '../utils/module-format';
8
9
 
9
10
  export type PresetContainersOption = Containers | 'infer';
10
11
 
@@ -13,5 +14,6 @@ export interface PresetGeneratorSchema {
13
14
  readonly gitSecrets?: boolean;
14
15
  readonly mcp?: boolean;
15
16
  readonly containers?: PresetContainersOption;
17
+ readonly module?: ModuleFormat;
16
18
  readonly preferInstallDependencies?: boolean;
17
19
  }
@@ -31,6 +31,12 @@
31
31
  "x-priority": "important",
32
32
  "x-prompt": "Which container engine would you like to use? (default: infer)"
33
33
  },
34
+ "module": {
35
+ "type": "string",
36
+ "description": "Module format for generated TypeScript code and configuration.",
37
+ "enum": ["esm", "cjs"],
38
+ "default": "esm"
39
+ },
34
40
  "preferInstallDependencies": {
35
41
  "type": "boolean",
36
42
  "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.",
@@ -283,17 +283,17 @@ dependencies = [
283
283
  "proj-agent-connection",
284
284
  "aws-lambda-powertools==3.31.0",
285
285
  "aws-opentelemetry-distro==0.18.0",
286
- "bedrock-agentcore==1.15.1",
287
- "boto3==1.43.37",
288
- "fastapi==0.138.2",
286
+ "bedrock-agentcore==1.18.0",
287
+ "boto3==1.43.46",
288
+ "fastapi==0.139.0",
289
289
  "mcp==1.28.1",
290
- "strands-agents==1.45.0",
291
- "strands-agents-tools==0.8.2",
292
- "uvicorn==0.49.0"
290
+ "strands-agents==1.47.0",
291
+ "strands-agents-tools==0.8.3",
292
+ "uvicorn==0.51.0"
293
293
  ]
294
294
 
295
295
  [dependency-groups]
296
- dev = [ "fastapi[standard]==0.138.2" ]
296
+ dev = [ "fastapi[standard]==0.139.0" ]
297
297
 
298
298
  [tool.uv]
299
299
  dev-dependencies = [ ]
@@ -710,20 +710,20 @@ dependencies = [
710
710
  "proj-agent-connection",
711
711
  "aws-lambda-powertools==3.31.0",
712
712
  "aws-opentelemetry-distro==0.18.0",
713
- "bedrock-agentcore==1.15.1",
714
- "boto3==1.43.37",
715
- "fastapi==0.138.2",
713
+ "bedrock-agentcore==1.18.0",
714
+ "boto3==1.43.46",
715
+ "fastapi==0.139.0",
716
716
  "mcp==1.28.1",
717
- "langchain==1.3.11",
718
- "langchain-aws==1.6.1",
719
- "langgraph==1.2.7",
717
+ "langchain==1.3.12",
718
+ "langchain-aws==1.6.2",
719
+ "langgraph==1.2.9",
720
720
  "ag-ui-protocol==0.1.19",
721
721
  "ag-ui-langgraph==0.0.42",
722
- "uvicorn==0.49.0"
722
+ "uvicorn==0.51.0"
723
723
  ]
724
724
 
725
725
  [dependency-groups]
726
- dev = [ "fastapi[standard]==0.138.2" ]
726
+ dev = [ "fastapi[standard]==0.139.0" ]
727
727
 
728
728
  [tool.uv]
729
729
  dev-dependencies = [ ]
@@ -23,6 +23,25 @@ variable "tags" {
23
23
  default = {}
24
24
  }
25
25
 
26
+ # VPC Configuration (optional)
27
+ variable "enable_vpc" {
28
+ description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
29
+ type = bool
30
+ default = false
31
+ }
32
+
33
+ variable "vpc_id" {
34
+ description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
35
+ type = string
36
+ default = null
37
+ }
38
+
39
+ variable "subnet_ids" {
40
+ description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
41
+ type = list(string)
42
+ default = null
43
+ }
44
+
26
45
  variable "appconfig_application_id" {
27
46
  description = "ID of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_id\`). The agent reads its runtime configuration from this application."
28
47
  type = string
@@ -38,6 +57,9 @@ module "agent_core_runtime" {
38
57
  agent_runtime_name = "TerraformSnapshotAgent"
39
58
  docker_image_tag = "proj-terraform-snapshot-agent:latest"
40
59
  server_protocol = "HTTP"
60
+ enable_vpc = var.enable_vpc
61
+ vpc_id = var.vpc_id
62
+ subnet_ids = var.subnet_ids
41
63
 
42
64
  env = merge({
43
65
  RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
@@ -92,6 +114,11 @@ output "appconfig_application_id" {
92
114
  description = "AppConfig Application ID for runtime config (passthrough of the shared \`appconfig_application_id\` input)."
93
115
  value = var.appconfig_application_id
94
116
  }
117
+
118
+ output "security_group_id" {
119
+ description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
120
+ value = module.agent_core_runtime.security_group_id
121
+ }
95
122
  "
96
123
  `;
97
124
 
@@ -102,7 +129,7 @@ exports[`py#agent generator > should match snapshot for Terraform generated file
102
129
  required_providers {
103
130
  aws = {
104
131
  source = "hashicorp/aws"
105
- version = "6.52.0"
132
+ version = "6.54.0"
106
133
  }
107
134
  null = {
108
135
  source = "hashicorp/null"
@@ -168,6 +195,30 @@ variable "additional_iam_policy_statements" {
168
195
  default = []
169
196
  }
170
197
 
198
+ # VPC Configuration (optional)
199
+ variable "enable_vpc" {
200
+ description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
201
+ type = bool
202
+ default = false
203
+ }
204
+
205
+ variable "vpc_id" {
206
+ description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
207
+ type = string
208
+ default = null
209
+
210
+ validation {
211
+ condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
212
+ error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
213
+ }
214
+ }
215
+
216
+ variable "subnet_ids" {
217
+ description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
218
+ type = list(string)
219
+ default = null
220
+ }
221
+
171
222
  variable "tags" {
172
223
  description = "Tags to apply to resources"
173
224
  type = map(string)
@@ -403,6 +454,28 @@ resource "null_resource" "docker_publish" {
403
454
  depends_on = [aws_ecr_repository_policy.agent_core_ecr_policy]
404
455
  }
405
456
 
457
+ # Security group for the agent core runtime, used when running inside a VPC
458
+ resource "aws_security_group" "agent_core_runtime" {
459
+ count = var.enable_vpc ? 1 : 0
460
+
461
+ #checkov:skip=CKV2_AWS_5:Attached to the runtime via network_configuration; Checkov cannot resolve this reference
462
+ name_prefix = "\${var.agent_runtime_name}-runtime-"
463
+ description = "Security group for the \${var.agent_runtime_name} agent core runtime"
464
+ vpc_id = var.vpc_id
465
+ tags = var.tags
466
+ }
467
+
468
+ resource "aws_vpc_security_group_egress_rule" "agent_core_runtime_https" {
469
+ count = var.enable_vpc ? 1 : 0
470
+
471
+ security_group_id = aws_security_group.agent_core_runtime[0].id
472
+ cidr_ipv4 = "0.0.0.0/0"
473
+ from_port = 443
474
+ to_port = 443
475
+ ip_protocol = "tcp"
476
+ description = "Allow outbound HTTPS to AWS service endpoints"
477
+ }
478
+
406
479
  # Bedrock AgentCore Agent Runtime
407
480
  resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
408
481
  agent_runtime_name = "\${var.agent_runtime_name}_\${random_id.unique_suffix.hex}"
@@ -429,7 +502,15 @@ resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
429
502
  }
430
503
 
431
504
  network_configuration {
432
- network_mode = "PUBLIC"
505
+ network_mode = var.enable_vpc ? "VPC" : "PUBLIC"
506
+
507
+ dynamic "network_mode_config" {
508
+ for_each = var.enable_vpc ? [1] : []
509
+ content {
510
+ security_groups = [aws_security_group.agent_core_runtime[0].id]
511
+ subnets = var.subnet_ids
512
+ }
513
+ }
433
514
  }
434
515
 
435
516
  protocol_configuration {
@@ -456,7 +537,7 @@ resource "null_resource" "runtime_ready" {
456
537
 
457
538
  provisioner "local-exec" {
458
539
  command = <<-EOT
459
- uv run --with boto3==1.43.37 python -c "
540
+ uv run --with boto3==1.43.46 python -c "
460
541
  import boto3
461
542
  import json
462
543
  import os
@@ -531,5 +612,10 @@ output "agent_runtime_version" {
531
612
  description = "Version of the Bedrock Agent Core runtime"
532
613
  value = aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_version
533
614
  }
615
+
616
+ output "security_group_id" {
617
+ description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
618
+ value = var.enable_vpc ? aws_security_group.agent_core_runtime[0].id : null
619
+ }
534
620
  "
535
621
  `;
@@ -35,7 +35,7 @@ exports[`py#dynamodb generator > should generate terraform modules when iac is t
35
35
  required_providers {
36
36
  aws = {
37
37
  source = "hashicorp/aws"
38
- version = "6.52.0"
38
+ version = "6.54.0"
39
39
  }
40
40
  }
41
41
  }
@@ -192,7 +192,7 @@ exports[`py#dynamodb generator > should generate terraform modules when iac is t
192
192
  required_providers {
193
193
  aws = {
194
194
  source = "hashicorp/aws"
195
- version = "6.52.0"
195
+ version = "6.54.0"
196
196
  }
197
197
  random = {
198
198
  source = "hashicorp/random"
@@ -11,7 +11,7 @@ terraform {
11
11
  required_providers {
12
12
  aws = {
13
13
  source = "hashicorp/aws"
14
- version = "6.52.0"
14
+ version = "6.54.0"
15
15
  }
16
16
  }
17
17
  }
@@ -258,7 +258,7 @@ output "api_log_group_arn" {
258
258
  required_providers {
259
259
  aws = {
260
260
  source = "hashicorp/aws"
261
- version = "6.52.0"
261
+ version = "6.54.0"
262
262
  }
263
263
  }
264
264
  }
@@ -743,7 +743,7 @@ terraform {
743
743
  required_providers {
744
744
  aws = {
745
745
  source = "hashicorp/aws"
746
- version = "6.52.0"
746
+ version = "6.54.0"
747
747
  }
748
748
  }
749
749
  }
@@ -990,7 +990,7 @@ output "api_log_group_arn" {
990
990
  required_providers {
991
991
  aws = {
992
992
  source = "hashicorp/aws"
993
- version = "6.52.0"
993
+ version = "6.54.0"
994
994
  }
995
995
  }
996
996
  }
@@ -1547,7 +1547,7 @@ terraform {
1547
1547
  required_providers {
1548
1548
  aws = {
1549
1549
  source = "hashicorp/aws"
1550
- version = "6.52.0"
1550
+ version = "6.54.0"
1551
1551
  }
1552
1552
  }
1553
1553
  }
@@ -1794,7 +1794,7 @@ output "api_log_group_arn" {
1794
1794
  required_providers {
1795
1795
  aws = {
1796
1796
  source = "hashicorp/aws"
1797
- version = "6.52.0"
1797
+ version = "6.54.0"
1798
1798
  }
1799
1799
  }
1800
1800
  }
@@ -2256,7 +2256,7 @@ terraform {
2256
2256
  required_providers {
2257
2257
  aws = {
2258
2258
  source = "hashicorp/aws"
2259
- version = "6.52.0"
2259
+ version = "6.54.0"
2260
2260
  }
2261
2261
  random = {
2262
2262
  source = "hashicorp/random"
@@ -2512,7 +2512,7 @@ output "waf_web_acl_arn" {
2512
2512
  required_providers {
2513
2513
  aws = {
2514
2514
  source = "hashicorp/aws"
2515
- version = "6.52.0"
2515
+ version = "6.54.0"
2516
2516
  }
2517
2517
  }
2518
2518
  }
@@ -3234,7 +3234,7 @@ terraform {
3234
3234
  required_providers {
3235
3235
  aws = {
3236
3236
  source = "hashicorp/aws"
3237
- version = "6.52.0"
3237
+ version = "6.54.0"
3238
3238
  }
3239
3239
  random = {
3240
3240
  source = "hashicorp/random"
@@ -3490,7 +3490,7 @@ output "waf_web_acl_arn" {
3490
3490
  required_providers {
3491
3491
  aws = {
3492
3492
  source = "hashicorp/aws"
3493
- version = "6.52.0"
3493
+ version = "6.54.0"
3494
3494
  }
3495
3495
  }
3496
3496
  }
@@ -4201,7 +4201,7 @@ terraform {
4201
4201
  required_providers {
4202
4202
  aws = {
4203
4203
  source = "hashicorp/aws"
4204
- version = "6.52.0"
4204
+ version = "6.54.0"
4205
4205
  }
4206
4206
  random = {
4207
4207
  source = "hashicorp/random"
@@ -4457,7 +4457,7 @@ output "waf_web_acl_arn" {
4457
4457
  required_providers {
4458
4458
  aws = {
4459
4459
  source = "hashicorp/aws"
4460
- version = "6.52.0"
4460
+ version = "6.54.0"
4461
4461
  }
4462
4462
  }
4463
4463
  }
@@ -70,7 +70,7 @@ exports[`lambda-handler project generator > terraform iac > should generate terr
70
70
  required_providers {
71
71
  aws = {
72
72
  source = "hashicorp/aws"
73
- version = "6.52.0"
73
+ version = "6.54.0"
74
74
  }
75
75
  archive = {
76
76
  source = "hashicorp/archive"
@@ -251,7 +251,7 @@ exports[`lambda-handler project generator > terraform iac > should match snapsho
251
251
  required_providers {
252
252
  aws = {
253
253
  source = "hashicorp/aws"
254
- version = "6.52.0"
254
+ version = "6.54.0"
255
255
  }
256
256
  archive = {
257
257
  source = "hashicorp/archive"
@@ -135,7 +135,7 @@ exports[`py#mcp-server generator > should match snapshot for Terraform generated
135
135
  required_providers {
136
136
  aws = {
137
137
  source = "hashicorp/aws"
138
- version = "6.52.0"
138
+ version = "6.54.0"
139
139
  }
140
140
  null = {
141
141
  source = "hashicorp/null"
@@ -201,6 +201,30 @@ variable "additional_iam_policy_statements" {
201
201
  default = []
202
202
  }
203
203
 
204
+ # VPC Configuration (optional)
205
+ variable "enable_vpc" {
206
+ description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
207
+ type = bool
208
+ default = false
209
+ }
210
+
211
+ variable "vpc_id" {
212
+ description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
213
+ type = string
214
+ default = null
215
+
216
+ validation {
217
+ condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
218
+ error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
219
+ }
220
+ }
221
+
222
+ variable "subnet_ids" {
223
+ description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
224
+ type = list(string)
225
+ default = null
226
+ }
227
+
204
228
  variable "tags" {
205
229
  description = "Tags to apply to resources"
206
230
  type = map(string)
@@ -436,6 +460,28 @@ resource "null_resource" "docker_publish" {
436
460
  depends_on = [aws_ecr_repository_policy.agent_core_ecr_policy]
437
461
  }
438
462
 
463
+ # Security group for the agent core runtime, used when running inside a VPC
464
+ resource "aws_security_group" "agent_core_runtime" {
465
+ count = var.enable_vpc ? 1 : 0
466
+
467
+ #checkov:skip=CKV2_AWS_5:Attached to the runtime via network_configuration; Checkov cannot resolve this reference
468
+ name_prefix = "\${var.agent_runtime_name}-runtime-"
469
+ description = "Security group for the \${var.agent_runtime_name} agent core runtime"
470
+ vpc_id = var.vpc_id
471
+ tags = var.tags
472
+ }
473
+
474
+ resource "aws_vpc_security_group_egress_rule" "agent_core_runtime_https" {
475
+ count = var.enable_vpc ? 1 : 0
476
+
477
+ security_group_id = aws_security_group.agent_core_runtime[0].id
478
+ cidr_ipv4 = "0.0.0.0/0"
479
+ from_port = 443
480
+ to_port = 443
481
+ ip_protocol = "tcp"
482
+ description = "Allow outbound HTTPS to AWS service endpoints"
483
+ }
484
+
439
485
  # Bedrock AgentCore Agent Runtime
440
486
  resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
441
487
  agent_runtime_name = "\${var.agent_runtime_name}_\${random_id.unique_suffix.hex}"
@@ -462,7 +508,15 @@ resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
462
508
  }
463
509
 
464
510
  network_configuration {
465
- network_mode = "PUBLIC"
511
+ network_mode = var.enable_vpc ? "VPC" : "PUBLIC"
512
+
513
+ dynamic "network_mode_config" {
514
+ for_each = var.enable_vpc ? [1] : []
515
+ content {
516
+ security_groups = [aws_security_group.agent_core_runtime[0].id]
517
+ subnets = var.subnet_ids
518
+ }
519
+ }
466
520
  }
467
521
 
468
522
  protocol_configuration {
@@ -489,7 +543,7 @@ resource "null_resource" "runtime_ready" {
489
543
 
490
544
  provisioner "local-exec" {
491
545
  command = <<-EOT
492
- uv run --with boto3==1.43.37 python -c "
546
+ uv run --with boto3==1.43.46 python -c "
493
547
  import boto3
494
548
  import json
495
549
  import os
@@ -564,6 +618,11 @@ output "agent_runtime_version" {
564
618
  description = "Version of the Bedrock Agent Core runtime"
565
619
  value = aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_version
566
620
  }
621
+
622
+ output "security_group_id" {
623
+ description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
624
+ value = var.enable_vpc ? aws_security_group.agent_core_runtime[0].id : null
625
+ }
567
626
  "
568
627
  `;
569
628
 
@@ -590,6 +649,25 @@ variable "tags" {
590
649
  default = {}
591
650
  }
592
651
 
652
+ # VPC Configuration (optional)
653
+ variable "enable_vpc" {
654
+ description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
655
+ type = bool
656
+ default = false
657
+ }
658
+
659
+ variable "vpc_id" {
660
+ description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
661
+ type = string
662
+ default = null
663
+ }
664
+
665
+ variable "subnet_ids" {
666
+ description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
667
+ type = list(string)
668
+ default = null
669
+ }
670
+
593
671
  variable "appconfig_application_id" {
594
672
  description = "ID of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_id\`). The agent reads its runtime configuration from this application."
595
673
  type = string
@@ -605,6 +683,9 @@ module "agent_core_runtime" {
605
683
  agent_runtime_name = "TerraformSnapshotServer"
606
684
  docker_image_tag = "proj-terraform-snapshot-server:latest"
607
685
  server_protocol = "MCP"
686
+ enable_vpc = var.enable_vpc
687
+ vpc_id = var.vpc_id
688
+ subnet_ids = var.subnet_ids
608
689
 
609
690
  env = merge({
610
691
  RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
@@ -647,6 +728,11 @@ output "appconfig_application_id" {
647
728
  description = "AppConfig Application ID for runtime config (passthrough of the shared \`appconfig_application_id\` input)."
648
729
  value = var.appconfig_application_id
649
730
  }
731
+
732
+ output "security_group_id" {
733
+ description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
734
+ value = module.agent_core_runtime.security_group_id
735
+ }
650
736
  "
651
737
  `;
652
738
 
@@ -718,8 +804,8 @@ version = "0.1.0"
718
804
  dependencies = [
719
805
  "aws-lambda-powertools==3.31.0",
720
806
  "mcp==1.28.1",
721
- "uvicorn==0.49.0",
722
- "boto3==1.43.37",
807
+ "uvicorn==0.51.0",
808
+ "boto3==1.43.46",
723
809
  "aws-opentelemetry-distro==0.18.0"
724
810
  ]
725
811