@aws/nx-plugin 0.109.0 → 0.110.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.
Files changed (42) hide show
  1. package/package.json +1 -1
  2. package/src/preset/__snapshots__/generator.spec.ts.snap +11 -1
  3. package/src/preset/generator.js +12 -3
  4. package/src/preset/generator.js.map +1 -1
  5. package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +184 -106
  6. package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +74 -18
  7. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +11 -9
  8. package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +11 -9
  9. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +114 -62
  10. package/src/terraform/project/files/application/scripts/aws-config.ts.template +41 -0
  11. package/src/terraform/project/files/application/scripts/bootstrap.ts.template +91 -0
  12. package/src/terraform/project/files/application/scripts/init.ts.template +44 -0
  13. package/src/terraform/project/generator.js +16 -11
  14. package/src/terraform/project/generator.js.map +1 -1
  15. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +175 -97
  16. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +74 -18
  17. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +11 -9
  18. package/src/ts/react-website/agui/generator.js +7 -0
  19. package/src/ts/react-website/agui/generator.js.map +1 -1
  20. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +7 -0
  21. package/src/ts/strands-agent/__snapshots__/generator.spec.ts.snap +11 -9
  22. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +14 -12
  23. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +30 -17
  24. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +32 -19
  25. package/src/utils/api-constructs/files/terraform/core/api/http/http-api/http-api.tf.template +2 -2
  26. package/src/utils/files/terraform/scripts/reset-runtime-config.ts.template +25 -0
  27. package/src/utils/files/terraform/src/core/asset-bucket/asset-bucket.tf.template +203 -0
  28. package/src/utils/files/terraform/src/core/runtime-config/appconfig/appconfig.tf.template +42 -39
  29. package/src/utils/files/terraform/src/core/runtime-config/appconfig-deployment/appconfig-deployment.tf.template +138 -0
  30. package/src/utils/files/terraform/src/core/runtime-config/entry/entry.tf.template +26 -90
  31. package/src/utils/files/terraform/src/core/runtime-config/read/read.tf.template +61 -5
  32. package/src/utils/function-constructs/files/terraform/app/lambda-functions/__functionNameKebabCase__/__functionNameKebabCase__.tf.template +36 -8
  33. package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +6 -6
  34. package/src/utils/pnpm-workspace.d.ts +22 -0
  35. package/src/utils/pnpm-workspace.js +58 -0
  36. package/src/utils/pnpm-workspace.js.map +1 -0
  37. package/src/utils/shared-constructs.js +4 -2
  38. package/src/utils/shared-constructs.js.map +1 -1
  39. package/src/utils/versions.d.ts +4 -1
  40. package/src/utils/versions.js +3 -0
  41. package/src/utils/versions.js.map +1 -1
  42. package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +7 -0
@@ -135,7 +135,20 @@ export const handler = middy()
135
135
 
136
136
  exports[`ts-lambda-function generator > terraform iacProvider > should generate terraform files for lambda function and snapshot them > terraform-lambda-files 1`] = `
137
137
  {
138
- "test-project-test-function.tf": "variable "tags" {
138
+ "test-project-test-function.tf": "terraform {
139
+ required_providers {
140
+ aws = {
141
+ source = "hashicorp/aws"
142
+ version = "~> 6.0"
143
+ }
144
+ archive = {
145
+ source = "hashicorp/archive"
146
+ version = "~> 2.0"
147
+ }
148
+ }
149
+ }
150
+
151
+ variable "tags" {
139
152
  description = "Tags to apply to resources"
140
153
  type = map(string)
141
154
  default = {}
@@ -157,12 +170,17 @@ variable "additional_iam_policy_statements" {
157
170
  default = []
158
171
  }
159
172
 
173
+ variable "asset_bucket_name" {
174
+ 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."
175
+ type = string
176
+ }
177
+
160
178
  data "aws_caller_identity" "current" {}
161
179
  data "aws_region" "current" {}
162
180
 
163
181
  locals {
164
182
  aws_account_id = data.aws_caller_identity.current.account_id
165
- aws_region = data.aws_region.current.name
183
+ aws_region = data.aws_region.current.region
166
184
  }
167
185
 
168
186
  resource "random_string" "suffix" {
@@ -237,19 +255,29 @@ data "archive_file" "lambda_zip" {
237
255
  output_path = "\${path.module}/../../../../../../../dist/packages/common/terraform/lambda-functions/test-project-test-function/lambda.zip"
238
256
  }
239
257
 
258
+ resource "aws_s3_object" "lambda_zip" {
259
+ bucket = var.asset_bucket_name
260
+ key = "lambdas/test-project-test-function/\${data.archive_file.lambda_zip.output_base64sha256}.zip"
261
+ source = data.archive_file.lambda_zip.output_path
262
+ source_hash = data.archive_file.lambda_zip.output_base64sha256
263
+ etag = data.archive_file.lambda_zip.output_md5
264
+ }
265
+
240
266
  resource "aws_lambda_function" "lambda_function" {
241
267
  #checkov:skip=CKV_AWS_117:Lambda function does not need to be in VPC for this use case
242
268
  #checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple use case
243
269
  #checkov:skip=CKV_AWS_272:Code signing not required for this use case
244
270
  #checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
245
271
  #checkov:skip=CKV_AWS_173:Lambda environment variables encrypted by managed key
246
- filename = data.archive_file.lambda_zip.output_path
247
- function_name = "test-project-test-function-\${random_string.suffix.result}"
248
- role = aws_iam_role.lambda_role.arn
249
- handler = "index.handler"
250
- source_code_hash = data.archive_file.lambda_zip.output_base64sha256
251
- runtime = "nodejs22.x"
252
- timeout = 30
272
+ s3_bucket = aws_s3_object.lambda_zip.bucket
273
+ s3_key = aws_s3_object.lambda_zip.key
274
+ s3_object_version = aws_s3_object.lambda_zip.version_id
275
+ function_name = "test-project-test-function-\${random_string.suffix.result}"
276
+ role = aws_iam_role.lambda_role.arn
277
+ handler = "index.handler"
278
+ source_code_hash = data.archive_file.lambda_zip.output_base64sha256
279
+ runtime = "nodejs22.x"
280
+ timeout = 30
253
281
 
254
282
  tracing_config {
255
283
  mode = "Active"
@@ -288,7 +316,20 @@ output "role_name" {
288
316
  `;
289
317
 
290
318
  exports[`ts-lambda-function generator > terraform iacProvider > should match snapshot for terraform generated files with different configurations > terraform-lambda-snapshot-function.tf 1`] = `
291
- "variable "tags" {
319
+ "terraform {
320
+ required_providers {
321
+ aws = {
322
+ source = "hashicorp/aws"
323
+ version = "~> 6.0"
324
+ }
325
+ archive = {
326
+ source = "hashicorp/archive"
327
+ version = "~> 2.0"
328
+ }
329
+ }
330
+ }
331
+
332
+ variable "tags" {
292
333
  description = "Tags to apply to resources"
293
334
  type = map(string)
294
335
  default = {}
@@ -310,12 +351,17 @@ variable "additional_iam_policy_statements" {
310
351
  default = []
311
352
  }
312
353
 
354
+ variable "asset_bucket_name" {
355
+ 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."
356
+ type = string
357
+ }
358
+
313
359
  data "aws_caller_identity" "current" {}
314
360
  data "aws_region" "current" {}
315
361
 
316
362
  locals {
317
363
  aws_account_id = data.aws_caller_identity.current.account_id
318
- aws_region = data.aws_region.current.name
364
+ aws_region = data.aws_region.current.region
319
365
  }
320
366
 
321
367
  resource "random_string" "suffix" {
@@ -390,19 +436,29 @@ data "archive_file" "lambda_zip" {
390
436
  output_path = "\${path.module}/../../../../../../../dist/packages/common/terraform/lambda-functions/test-project-snapshot-function/lambda.zip"
391
437
  }
392
438
 
439
+ resource "aws_s3_object" "lambda_zip" {
440
+ bucket = var.asset_bucket_name
441
+ key = "lambdas/test-project-snapshot-function/\${data.archive_file.lambda_zip.output_base64sha256}.zip"
442
+ source = data.archive_file.lambda_zip.output_path
443
+ source_hash = data.archive_file.lambda_zip.output_base64sha256
444
+ etag = data.archive_file.lambda_zip.output_md5
445
+ }
446
+
393
447
  resource "aws_lambda_function" "lambda_function" {
394
448
  #checkov:skip=CKV_AWS_117:Lambda function does not need to be in VPC for this use case
395
449
  #checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple use case
396
450
  #checkov:skip=CKV_AWS_272:Code signing not required for this use case
397
451
  #checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
398
452
  #checkov:skip=CKV_AWS_173:Lambda environment variables encrypted by managed key
399
- filename = data.archive_file.lambda_zip.output_path
400
- function_name = "test-project-snapshot-function-\${random_string.suffix.result}"
401
- role = aws_iam_role.lambda_role.arn
402
- handler = "index.handler"
403
- source_code_hash = data.archive_file.lambda_zip.output_base64sha256
404
- runtime = "nodejs22.x"
405
- timeout = 30
453
+ s3_bucket = aws_s3_object.lambda_zip.bucket
454
+ s3_key = aws_s3_object.lambda_zip.key
455
+ s3_object_version = aws_s3_object.lambda_zip.version_id
456
+ function_name = "test-project-snapshot-function-\${random_string.suffix.result}"
457
+ role = aws_iam_role.lambda_role.arn
458
+ handler = "index.handler"
459
+ source_code_hash = data.archive_file.lambda_zip.output_base64sha256
460
+ runtime = "nodejs22.x"
461
+ timeout = 30
406
462
 
407
463
  tracing_config {
408
464
  mode = "Active"
@@ -520,10 +520,14 @@ variable "tags" {
520
520
  default = {}
521
521
  }
522
522
 
523
- module "appconfig" {
524
- source = "../../../core/runtime-config/appconfig"
523
+ variable "appconfig_application_id" {
524
+ 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."
525
+ type = string
526
+ }
525
527
 
526
- application_name = "TerraformSnapshotServer-runtime-config"
528
+ variable "appconfig_application_arn" {
529
+ 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 agent runtime."
530
+ type = string
527
531
  }
528
532
 
529
533
  module "agent_core_runtime" {
@@ -533,7 +537,7 @@ module "agent_core_runtime" {
533
537
  server_protocol = "MCP"
534
538
 
535
539
  env = merge({
536
- RUNTIME_CONFIG_APP_ID = module.appconfig.application_id
540
+ RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
537
541
  }, var.env)
538
542
  additional_iam_policy_statements = concat([
539
543
  {
@@ -542,12 +546,10 @@ module "agent_core_runtime" {
542
546
  "appconfig:StartConfigurationSession",
543
547
  "appconfig:GetLatestConfiguration"
544
548
  ]
545
- Resource = ["\${module.appconfig.application_arn}/*"]
549
+ Resource = ["\${var.appconfig_application_arn}/*"]
546
550
  }
547
551
  ], var.additional_iam_policy_statements)
548
552
  tags = var.tags
549
-
550
- depends_on = [module.appconfig]
551
553
  }
552
554
 
553
555
  # Add agent runtime ARN to runtime config
@@ -572,8 +574,8 @@ output "agent_core_runtime_arn" {
572
574
  }
573
575
 
574
576
  output "appconfig_application_id" {
575
- description = "AppConfig Application ID for runtime config"
576
- value = module.appconfig.application_id
577
+ description = "AppConfig Application ID for runtime config (passthrough of the shared \`appconfig_application_id\` input)."
578
+ value = var.appconfig_application_id
577
579
  }
578
580
  "
579
581
  `;
@@ -13,6 +13,7 @@ const agent_runtime_config_1 = require("../../../connection/agent-runtime-config
13
13
  const names_1 = require("../../../utils/names");
14
14
  const shared_shadcn_1 = require("../../../utils/shared-shadcn");
15
15
  const npm_scope_1 = require("../../../utils/npm-scope");
16
+ const pnpm_workspace_1 = require("../../../utils/pnpm-workspace");
16
17
  /**
17
18
  * Wires a React website up to an AG-UI agent using CopilotKit and
18
19
  * @ag-ui/client's HttpAgent. Agent-server-language agnostic.
@@ -50,6 +51,12 @@ const addAgUiReactConnection = async (tree, options) => {
50
51
  const mainTsxPath = (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'main.tsx');
51
52
  await (0, ast_1.addSingleImport)(tree, mainTsxPath, 'AguiProvider', './components/AguiProvider');
52
53
  await (0, ast_1.applyGritQL)(tree, mainTsxPath, `\`<App />\` => \`<AguiProvider><App /></AguiProvider>\` where { $program <: not contains \`<AguiProvider>$_</AguiProvider>\` }`);
54
+ // @copilotkit/react-core transitively pulls in @scarf/scarf (telemetry),
55
+ // which has a postinstall script. Under pnpm 11's default
56
+ // `strictDepBuilds=true` that script is treated as an unreviewed build and
57
+ // fails the install. Register it as an explicitly-rejected build so pnpm
58
+ // knows we've seen it and will skip it instead of erroring.
59
+ (0, pnpm_workspace_1.registerPnpmBuiltDependencies)(tree, { '@scarf/scarf': false });
53
60
  (0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)([
54
61
  '@copilotkit/react-core',
55
62
  '@ag-ui/client',
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/agui/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,2DAAqE;AACrE,sDAAuD;AACvD,4CAI4B;AAC5B,mFAAgG;AAChG,gDAAiD;AACjD,gEAAqE;AACrE,wDAA2E;AAiB3E;;;;;;;;;;;GAWG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,IAAU,EACV,OAAmC,EACnC,EAAE;IACF,MAAM,EAAE,qBAAqB,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAClE,OAAO,CAAC;IAEV,MAAM,KAAK,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,IAAA,wBAAY,EAAC,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,8DAA8D;IAC9D,4EAA4E;IAC5E,+BAA+B;IAC/B,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EAC/C,qBAAqB,CAAC,IAAI,EAC1B,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,EACvC,EAAE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY,EAAE,CACtD,CAAC;IAEF,yEAA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,EAChC,YAAY,EACZ,kBAAkB,CACnB,CAAC;IACF,MAAM,QAAQ,GAAG,UAAU,kBAAkB,EAAE,CAAC;IAChD,wCAAwC;IACxC,MAAM,OAAO,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEpG,yBAAyB;IACzB,MAAM,IAAA,2BAAqB,EACzB,IAAI,EACJ,YAAY,EACZ,CAAC,QAAQ,CAAC,EACV,YAAY,QAAQ,EAAE,CACvB,CAAC;IAEF,6EAA6E;IAC7E,MAAM,IAAA,iBAAW,EACf,IAAI,EACJ,YAAY,EACZ,yFAAyF;QACvF,WAAW,OAAO,MAAM,QAAQ,yFAAyF;QACzH,4CAA4C,OAAO,MAAM,QAAQ,QAAQ,CAC5E,CAAC;IAEF,2EAA2E;IAC3E,oEAAoE;IACpE,2DAA2D;IAC3D,MAAM,IAAA,iBAAW,EACf,IAAI,EACJ,YAAY,EACZ,yEAAyE;QACvE,8BAA8B,OAAO,KAAK;QAC1C,yCAAyC,OAAO,QAAQ;QACxD,yDAAyD,OAAO,SAAS;QACzE,uCAAuC,OAAO,OAAO;QACrD,iDAAiD,OAAO,QAAQ;QAChE,IAAI,CACP,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/agui/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,2DAAqE;AACrE,sDAAuD;AACvD,4CAI4B;AAC5B,mFAAgG;AAChG,gDAAiD;AACjD,gEAAqE;AACrE,wDAA2E;AAC3E,kEAA8E;AAiB9E;;;;;;;;;;;GAWG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,IAAU,EACV,OAAmC,EACnC,EAAE;IACF,MAAM,EAAE,qBAAqB,EAAE,SAAS,EAAE,kBAAkB,EAAE,I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AAM,IAAA,iBAAW,EACf,IAAI,EACJ,YAAY,EACZ,yEAAyE;QACvE,8BAA8B,OAAO,KAAK;QAC1C,yCAAyC,OAAO,QAAQ;QACxD,yDAAyD,OAAO,SAAS;QACzE,uCAAuC,OAAO,OAAO;QACrD,iDAAiD,OAAO,QAAQ;QAChE,IAAI,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -587,6 +587,13 @@ resource "aws_cloudfront_distribution" "website" {
587
587
  aws_wafv2_web_acl.cloudfront_waf
588
588
  ]
589
589
  }
590
+
591
+ # CloudFront validates access to the distribution logs bucket when it
592
+ # creates the distribution.
593
+ depends_on = [
594
+ aws_s3_bucket_acl.distribution_logs_acl,
595
+ aws_s3_bucket_policy.distribution_logs_ssl_policy,
596
+ ]
590
597
  }
591
598
 
592
599
  # S3 Bucket Policy for CloudFront OAC
@@ -184,10 +184,14 @@ variable "tags" {
184
184
  default = {}
185
185
  }
186
186
 
187
- module "appconfig" {
188
- source = "../../../core/runtime-config/appconfig"
187
+ variable "appconfig_application_id" {
188
+ 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."
189
+ type = string
190
+ }
189
191
 
190
- application_name = "TerraformSnapshotAgent-runtime-config"
192
+ variable "appconfig_application_arn" {
193
+ 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 agent runtime."
194
+ type = string
191
195
  }
192
196
 
193
197
  module "agent_core_runtime" {
@@ -197,7 +201,7 @@ module "agent_core_runtime" {
197
201
  server_protocol = "HTTP"
198
202
 
199
203
  env = merge({
200
- RUNTIME_CONFIG_APP_ID = module.appconfig.application_id
204
+ RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
201
205
  }, var.env)
202
206
  additional_iam_policy_statements = concat([
203
207
  {
@@ -206,7 +210,7 @@ module "agent_core_runtime" {
206
210
  "appconfig:StartConfigurationSession",
207
211
  "appconfig:GetLatestConfiguration"
208
212
  ]
209
- Resource = ["\${module.appconfig.application_arn}/*"]
213
+ Resource = ["\${var.appconfig_application_arn}/*"]
210
214
  },
211
215
  # Grant access for the agent to invoke bedrock models
212
216
  {
@@ -222,8 +226,6 @@ module "agent_core_runtime" {
222
226
  }
223
227
  ], var.additional_iam_policy_statements)
224
228
  tags = var.tags
225
-
226
- depends_on = [module.appconfig]
227
229
  }
228
230
 
229
231
  # Add agent runtime ARN to runtime config
@@ -248,8 +250,8 @@ output "agent_core_runtime_arn" {
248
250
  }
249
251
 
250
252
  output "appconfig_application_id" {
251
- description = "AppConfig Application ID for runtime config"
252
- value = module.appconfig.application_id
253
+ description = "AppConfig Application ID for runtime config (passthrough of the shared \`appconfig_application_id\` input)."
254
+ value = var.appconfig_application_id
253
255
  }
254
256
  "
255
257
  `;
@@ -20,6 +20,16 @@ variable "tags" {
20
20
  default = {}
21
21
  }
22
22
 
23
+ variable "appconfig_application_id" {
24
+ 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."
25
+ type = string
26
+ }
27
+
28
+ variable "appconfig_application_arn" {
29
+ 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 agent runtime."
30
+ type = string
31
+ }
32
+
23
33
  <%_ if (auth === 'Cognito') { _%>
24
34
  variable "user_pool_id" {
25
35
  description = "ID of the user pool for cognito authentication"
@@ -38,12 +48,6 @@ locals {
38
48
  }
39
49
 
40
50
  <%_ } _%>
41
- module "appconfig" {
42
- source = "../../../core/runtime-config/appconfig"
43
-
44
- application_name = "<%= nameClassName %>-runtime-config"
45
- }
46
-
47
51
  module "agent_core_runtime" {
48
52
  source = "../../../core/agent-core"
49
53
  agent_runtime_name = "<%= nameClassName %>"
@@ -59,7 +63,7 @@ module "agent_core_runtime" {
59
63
  <%_ } _%>
60
64
 
61
65
  env = merge({
62
- RUNTIME_CONFIG_APP_ID = module.appconfig.application_id
66
+ RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
63
67
  }, var.env)
64
68
  additional_iam_policy_statements = concat([
65
69
  {
@@ -68,7 +72,7 @@ module "agent_core_runtime" {
68
72
  "appconfig:StartConfigurationSession",
69
73
  "appconfig:GetLatestConfiguration"
70
74
  ]
71
- Resource = ["${module.appconfig.application_arn}/*"]
75
+ Resource = ["${var.appconfig_application_arn}/*"]
72
76
  }<% if (serverProtocol !== 'MCP') { %>,
73
77
  # Grant access for the agent to invoke bedrock models
74
78
  {
@@ -84,8 +88,6 @@ module "agent_core_runtime" {
84
88
  }<% } %>
85
89
  ], var.additional_iam_policy_statements)
86
90
  tags = var.tags
87
-
88
- depends_on = [module.appconfig]
89
91
  }
90
92
 
91
93
  # Add agent runtime ARN to runtime config
@@ -110,6 +112,6 @@ output "agent_core_runtime_arn" {
110
112
  }
111
113
 
112
114
  output "appconfig_application_id" {
113
- description = "AppConfig Application ID for runtime config"
114
- value = module.appconfig.application_id
115
+ description = "AppConfig Application ID for runtime config (passthrough of the shared `appconfig_application_id` input)."
116
+ value = var.appconfig_application_id
115
117
  }
@@ -38,6 +38,11 @@ variable "additional_iam_policy_statements" {
38
38
  default = []
39
39
  }
40
40
 
41
+ variable "asset_bucket_name" {
42
+ 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."
43
+ type = string
44
+ }
45
+
41
46
  # CORS Configuration (passed to core module)
42
47
  variable "cors_allow_credentials" {
43
48
  description = "Whether to allow credentials in CORS requests"
@@ -86,6 +91,12 @@ variable "tags" {
86
91
  data "aws_region" "current" {}
87
92
  data "aws_caller_identity" "current" {}
88
93
 
94
+ resource "random_string" "suffix" {
95
+ length = 8
96
+ special = false
97
+ upper = false
98
+ }
99
+
89
100
  # Resources
90
101
 
91
102
  # Create Lambda ZIP file from the bundle directory
@@ -95,12 +106,20 @@ data "archive_file" "lambda_zip" {
95
106
  output_path = "${path.module}/../../../../../../../dist/packages/common/terraform/apis/<%- apiNameKebabCase %>/lambda.zip"
96
107
  }
97
108
 
109
+ resource "aws_s3_object" "lambda_zip" {
110
+ bucket = var.asset_bucket_name
111
+ key = "apis/<%- apiNameKebabCase %>/${data.archive_file.lambda_zip.output_base64sha256}.zip"
112
+ source = data.archive_file.lambda_zip.output_path
113
+ source_hash = data.archive_file.lambda_zip.output_base64sha256
114
+ etag = data.archive_file.lambda_zip.output_md5
115
+ }
116
+
98
117
 
99
118
  # Use the core HTTP API module
100
119
  module "http_api" {
101
120
  source = "../../../core/api/http-api"
102
121
 
103
- api_name = "<%- apiNameClassName %>"
122
+ api_name = "<%- apiNameClassName %>-${random_string.suffix.result}"
104
123
  api_description = "<%- apiNameClassName %> HTTP API"
105
124
  stage_name = "$default"
106
125
  stage_auto_deploy = true
@@ -125,8 +144,10 @@ resource "aws_lambda_function" "api_lambda" {
125
144
  #checkov:skip=CKV_AWS_272:Code signing not required for this use case
126
145
  #checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
127
146
  #checkov:skip=CKV_AWS_173:Lambda environment variables encrypted by managed key
128
- filename = data.archive_file.lambda_zip.output_path
129
- function_name = "<%- apiNameClassName %>Handler"
147
+ s3_bucket = aws_s3_object.lambda_zip.bucket
148
+ s3_key = aws_s3_object.lambda_zip.key
149
+ s3_object_version = aws_s3_object.lambda_zip.version_id
150
+ function_name = "<%- apiNameClassName %>Handler-${random_string.suffix.result}"
130
151
  role = aws_iam_role.lambda_execution_role.arn
131
152
  <%_ if (['trpc', 'smithy'].includes(backend.type)) { _%>
132
153
  handler = "index.handler"
@@ -134,7 +155,7 @@ resource "aws_lambda_function" "api_lambda" {
134
155
  <%_ } else if (backend.type === 'fastapi') { _%>
135
156
  handler = "run.sh"
136
157
  runtime = "python3.14"
137
- layers = ["arn:aws:lambda:${data.aws_region.current.name}:753240598075:layer:LambdaAdapterLayerX86:24"]
158
+ layers = ["arn:aws:lambda:${data.aws_region.current.region}:753240598075:layer:LambdaAdapterLayerX86:24"]
138
159
  <%_ } _%>
139
160
  timeout = 30
140
161
  memory_size = 128
@@ -171,7 +192,7 @@ resource "aws_lambda_function" "api_lambda" {
171
192
 
172
193
  # IAM role for Lambda execution
173
194
  resource "aws_iam_role" "lambda_execution_role" {
174
- name = "<%- apiNameClassName %>Handler-execution-role"
195
+ name = "<%- apiNameClassName %>Handler-execution-role-${random_string.suffix.result}"
175
196
 
176
197
  assume_role_policy = jsonencode({
177
198
  Version = "2012-10-17"
@@ -204,7 +225,7 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
204
225
  # Additional IAM policies for Lambda (if provided)
205
226
  resource "aws_iam_role_policy" "lambda_additional_policies" {
206
227
  count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
207
- name = "<%- apiNameClassName %>Handler-additional-policies"
228
+ name = "<%- apiNameClassName %>Handler-additional-policies-${random_string.suffix.result}"
208
229
  role = aws_iam_role.lambda_execution_role.id
209
230
 
210
231
  policy = jsonencode({
@@ -218,7 +239,7 @@ resource "aws_cloudwatch_log_group" "lambda_logs" {
218
239
  #checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
219
240
  #checkov:skip=CKV_AWS_338:Log retention set to forever
220
241
  #checkov:skip=CKV_AWS_66:Log retention set to forever
221
- name = "/aws/lambda/<%- apiNameClassName %>Handler"
242
+ name = "/aws/lambda/<%- apiNameClassName %>Handler-${random_string.suffix.result}"
222
243
  tags = var.tags
223
244
  }
224
245
 
@@ -239,11 +260,11 @@ resource "aws_apigatewayv2_authorizer" "cognito_authorizer" {
239
260
  api_id = module.http_api.api_id
240
261
  authorizer_type = "JWT"
241
262
  identity_sources = ["$request.header.Authorization"]
242
- name = "<%- apiNameClassName %>Authorizer"
263
+ name = "<%- apiNameClassName %>Authorizer-${random_string.suffix.result}"
243
264
 
244
265
  jwt_configuration {
245
266
  audience = var.user_pool_client_ids
246
- issuer = "https://cognito-idp.${data.aws_region.current.name}.amazonaws.com/${var.user_pool_id}"
267
+ issuer = "https://cognito-idp.${data.aws_region.current.region}.amazonaws.com/${var.user_pool_id}"
247
268
  }
248
269
  }
249
270
  <%_ } _%>
@@ -303,14 +324,6 @@ module "add_url_to_runtime_config" {
303
324
  depends_on = [module.http_api]
304
325
  }
305
326
 
306
- module "appconfig" {
307
- source = "../../../core/runtime-config/appconfig"
308
-
309
- application_name = "<%- apiNameClassName %>-runtime-config"
310
-
311
- depends_on = [module.add_url_to_runtime_config]
312
- }
313
-
314
327
  # Lambda permission for API Gateway to invoke the function<% if (backend.type === 'fastapi') { %> via alias<% } %>
315
328
  resource "aws_lambda_permission" "api_gateway_invoke" {
316
329
  statement_id = "AllowExecutionFromAPIGateway"
@@ -38,6 +38,11 @@ variable "additional_iam_policy_statements" {
38
38
  default = []
39
39
  }
40
40
 
41
+ variable "asset_bucket_name" {
42
+ 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."
43
+ type = string
44
+ }
45
+
41
46
  # CORS Configuration (passed to core module)
42
47
 
43
48
  variable "cors_allow_headers" {
@@ -76,20 +81,34 @@ variable "tags" {
76
81
  data "aws_region" "current" {}
77
82
  data "aws_caller_identity" "current" {}
78
83
 
84
+ resource "random_string" "suffix" {
85
+ length = 8
86
+ special = false
87
+ upper = false
88
+ }
89
+
79
90
  # Resources
80
91
 
81
- # Create Lambda ZIP file from the FastAPI bundle directory
92
+ # Create Lambda ZIP file from the bundle directory
82
93
  data "archive_file" "lambda_zip" {
83
94
  type = "zip"
84
95
  source_dir = "${path.module}/../../../../../../../<%- backend.bundleOutputDir %>"
85
96
  output_path = "${path.module}/../../../../../../../dist/packages/common/terraform/apis/<%- apiNameKebabCase %>/lambda.zip"
86
97
  }
87
98
 
99
+ resource "aws_s3_object" "lambda_zip" {
100
+ bucket = var.asset_bucket_name
101
+ key = "apis/<%- apiNameKebabCase %>/${data.archive_file.lambda_zip.output_base64sha256}.zip"
102
+ source = data.archive_file.lambda_zip.output_path
103
+ source_hash = data.archive_file.lambda_zip.output_base64sha256
104
+ etag = data.archive_file.lambda_zip.output_md5
105
+ }
106
+
88
107
  # Use the core REST API module
89
108
  module "rest_api" {
90
109
  source = "../../../core/api/rest-api"
91
110
 
92
- api_name = "<%- apiNameClassName %>"
111
+ api_name = "<%- apiNameClassName %>-${random_string.suffix.result}"
93
112
  api_description = "<%- apiNameClassName %> REST API"
94
113
  stage_name = "prod"
95
114
  stage_auto_deploy = true
@@ -122,8 +141,10 @@ resource "aws_lambda_function" "api_lambda" {
122
141
  #checkov:skip=CKV_AWS_272:Code signing not required for this use case
123
142
  #checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
124
143
  #checkov:skip=CKV_AWS_173:Lambda environment variables encrypted by managed key
125
- filename = data.archive_file.lambda_zip.output_path
126
- function_name = "<%- apiNameClassName %>Handler"
144
+ s3_bucket = aws_s3_object.lambda_zip.bucket
145
+ s3_key = aws_s3_object.lambda_zip.key
146
+ s3_object_version = aws_s3_object.lambda_zip.version_id
147
+ function_name = "<%- apiNameClassName %>Handler-${random_string.suffix.result}"
127
148
  role = aws_iam_role.lambda_execution_role.arn
128
149
  <%_ if (['trpc', 'smithy'].includes(backend.type)) { _%>
129
150
  handler = "index.handler"
@@ -131,7 +152,7 @@ resource "aws_lambda_function" "api_lambda" {
131
152
  <%_ } else if (backend.type === 'fastapi') { _%>
132
153
  handler = "run.sh"
133
154
  runtime = "python3.14"
134
- layers = ["arn:aws:lambda:${data.aws_region.current.name}:753240598075:layer:LambdaAdapterLayerX86:24"]
155
+ layers = ["arn:aws:lambda:${data.aws_region.current.region}:753240598075:layer:LambdaAdapterLayerX86:24"]
135
156
  <%_ } _%>
136
157
  timeout = 30
137
158
  memory_size = 128
@@ -168,7 +189,7 @@ resource "aws_lambda_function" "api_lambda" {
168
189
 
169
190
  # IAM role for Lambda execution
170
191
  resource "aws_iam_role" "lambda_execution_role" {
171
- name = "<%- apiNameClassName %>Handler-execution-role"
192
+ name = "<%- apiNameClassName %>Handler-execution-role-${random_string.suffix.result}"
172
193
 
173
194
  assume_role_policy = jsonencode({
174
195
  Version = "2012-10-17"
@@ -201,7 +222,7 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
201
222
  # Additional IAM policies for Lambda (if provided)
202
223
  resource "aws_iam_role_policy" "lambda_additional_policies" {
203
224
  count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
204
- name = "<%- apiNameClassName %>Handler-additional-policies"
225
+ name = "<%- apiNameClassName %>Handler-additional-policies-${random_string.suffix.result}"
205
226
  role = aws_iam_role.lambda_execution_role.id
206
227
 
207
228
  policy = jsonencode({
@@ -215,7 +236,7 @@ resource "aws_cloudwatch_log_group" "lambda_logs" {
215
236
  #checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
216
237
  #checkov:skip=CKV_AWS_338:Log retention set to forever
217
238
  #checkov:skip=CKV_AWS_66:Log retention set to forever
218
- name = "/aws/lambda/<%- apiNameClassName %>Handler"
239
+ name = "/aws/lambda/<%- apiNameClassName %>Handler-${random_string.suffix.result}"
219
240
  tags = var.tags
220
241
  }
221
242
 
@@ -233,10 +254,10 @@ resource "aws_lambda_alias" "live" {
233
254
  <%_ if (auth === 'Cognito') { _%>
234
255
  # Cognito User Pool Authorizer
235
256
  resource "aws_api_gateway_authorizer" "cognito_authorizer" {
236
- name = "<%- apiNameClassName %>Authorizer"
257
+ name = "<%- apiNameClassName %>Authorizer-${random_string.suffix.result}"
237
258
  rest_api_id = module.rest_api.api_id
238
259
  type = "COGNITO_USER_POOLS"
239
- provider_arns = ["arn:aws:cognito-idp:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:userpool/${var.user_pool_id}"]
260
+ provider_arns = ["arn:aws:cognito-idp:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:userpool/${var.user_pool_id}"]
240
261
  identity_source = "method.request.header.Authorization"
241
262
  }
242
263
  <%_ } _%>
@@ -258,7 +279,7 @@ resource "aws_api_gateway_integration" "lambda_integration" {
258
279
  type = "AWS_PROXY"
259
280
  <%_ if (backend.type === 'fastapi') { _%>
260
281
  # Use the response streaming invocation path with the alias ARN for SnapStart
261
- uri = "arn:aws:apigateway:${data.aws_region.current.name}:lambda:path/2021-11-15/functions/${aws_lambda_alias.live.arn}/response-streaming-invocations"
282
+ uri = "arn:aws:apigateway:${data.aws_region.current.region}:lambda:path/2021-11-15/functions/${aws_lambda_alias.live.arn}/response-streaming-invocations"
262
283
  response_transfer_mode = "STREAM"
263
284
  <%_ } else if (backend.type === 'trpc') { _%>
264
285
  uri = aws_lambda_function.api_lambda.response_streaming_invoke_arn
@@ -480,14 +501,6 @@ module "add_url_to_runtime_config" {
480
501
  depends_on = [aws_api_gateway_stage.api_stage]
481
502
  }
482
503
 
483
- module "appconfig" {
484
- source = "../../../core/runtime-config/appconfig"
485
-
486
- application_name = "<%- apiNameClassName %>-runtime-config"
487
-
488
- depends_on = [module.add_url_to_runtime_config]
489
- }
490
-
491
504
  # Outputs
492
505
 
493
506
  # API Gateway Outputs (from core module)
@@ -111,7 +111,7 @@ resource "aws_kms_key" "logs_key" {
111
111
  Sid = "Allow CloudWatch Logs"
112
112
  Effect = "Allow"
113
113
  Principal = {
114
- Service = "logs.${data.aws_region.current.name}.amazonaws.com"
114
+ Service = "logs.${data.aws_region.current.region}.amazonaws.com"
115
115
  }
116
116
  Action = [
117
117
  "kms:Encrypt",
@@ -123,7 +123,7 @@ resource "aws_kms_key" "logs_key" {
123
123
  Resource = "*"
124
124
  Condition = {
125
125
  ArnEquals = {
126
- "kms:EncryptionContext:aws:logs:arn" = "arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:log-group:/aws/apigateway/${var.api_name}"
126
+ "kms:EncryptionContext:aws:logs:arn" = "arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:log-group:/aws/apigateway/${var.api_name}"
127
127
  }
128
128
  }
129
129
  }