@aws/nx-plugin 0.45.1 → 0.46.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 (63) hide show
  1. package/package.json +1 -1
  2. package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +3669 -0
  3. package/src/py/fast-api/generator.js +57 -50
  4. package/src/py/fast-api/generator.js.map +1 -1
  5. package/src/py/fast-api/schema.d.ts +1 -0
  6. package/src/py/fast-api/schema.json +8 -0
  7. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +590 -0
  8. package/src/py/mcp-server/generator.js +4 -18
  9. package/src/py/mcp-server/generator.js.map +1 -1
  10. package/src/py/mcp-server/schema.d.ts +1 -0
  11. package/src/py/mcp-server/schema.json +8 -0
  12. package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +590 -0
  13. package/src/py/strands-agent/generator.js +4 -18
  14. package/src/py/strands-agent/generator.js.map +1 -1
  15. package/src/py/strands-agent/schema.d.ts +1 -0
  16. package/src/py/strands-agent/schema.json +8 -0
  17. package/src/terraform/project/generator.js +23 -7
  18. package/src/terraform/project/generator.js.map +1 -1
  19. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +3669 -0
  20. package/src/trpc/backend/generator.js +6 -17
  21. package/src/trpc/backend/generator.js.map +1 -1
  22. package/src/trpc/backend/schema.d.ts +1 -0
  23. package/src/trpc/backend/schema.json +8 -0
  24. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +590 -0
  25. package/src/ts/mcp-server/generator.js +4 -18
  26. package/src/ts/mcp-server/generator.js.map +1 -1
  27. package/src/ts/mcp-server/schema.d.ts +1 -0
  28. package/src/ts/mcp-server/schema.json +8 -0
  29. package/src/ts/nx-plugin/generator.js +1 -0
  30. package/src/ts/nx-plugin/generator.js.map +1 -1
  31. package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +11 -5
  32. package/src/utils/agent-core-constructs/agent-core-constructs.js +51 -10
  33. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  34. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +46 -0
  35. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +536 -0
  36. package/src/utils/api-constructs/api-constructs.d.ts +4 -4
  37. package/src/utils/api-constructs/api-constructs.js +45 -5
  38. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  39. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +382 -0
  40. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +508 -0
  41. package/src/utils/api-constructs/files/terraform/core/api/http/http-api/http-api.tf.template +250 -0
  42. package/src/utils/api-constructs/files/terraform/core/api/rest/rest-api/rest-api.tf.template +150 -0
  43. package/src/utils/files/terraform/src/metrics/metrics.tf.template +3 -2
  44. package/src/utils/py.d.ts +5 -0
  45. package/src/utils/py.js +9 -1
  46. package/src/utils/py.js.map +1 -1
  47. package/src/utils/shared-constructs-constants.d.ts +2 -0
  48. package/src/utils/shared-constructs-constants.js +3 -1
  49. package/src/utils/shared-constructs-constants.js.map +1 -1
  50. package/src/utils/shared-constructs.js +2 -2
  51. package/src/utils/shared-constructs.js.map +1 -1
  52. package/src/utils/versions.d.ts +3 -1
  53. package/src/utils/versions.js +2 -0
  54. package/src/utils/versions.js.map +1 -1
  55. /package/src/utils/agent-core-constructs/files/{app → cdk/app}/agent-core/__nameKebabCase__/Dockerfile.template +0 -0
  56. /package/src/utils/agent-core-constructs/files/{app → cdk/app}/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +0 -0
  57. /package/src/utils/agent-core-constructs/files/{core → cdk/core}/agent-core/runtime.ts.template +0 -0
  58. /package/src/utils/api-constructs/files/{app → cdk/app}/apis/http/__apiNameKebabCase__.ts.template +0 -0
  59. /package/src/utils/api-constructs/files/{app → cdk/app}/apis/rest/__apiNameKebabCase__.ts.template +0 -0
  60. /package/src/utils/api-constructs/files/{core → cdk/core}/api/http/http-api.ts.template +0 -0
  61. /package/src/utils/api-constructs/files/{core → cdk/core}/api/rest/rest-api.ts.template +0 -0
  62. /package/src/utils/api-constructs/files/{core → cdk/core}/api/trpc/trpc-utils.ts.template +0 -0
  63. /package/src/utils/api-constructs/files/{core → cdk/core}/api/utils/utils.ts.template +0 -0
@@ -0,0 +1,382 @@
1
+ terraform {
2
+ required_version = ">= 1.0"
3
+
4
+ required_providers {
5
+ aws = {
6
+ source = "hashicorp/aws"
7
+ version = "~> 6.0"
8
+ }
9
+ }
10
+ }
11
+
12
+ <%_ if (auth === 'Cognito') { _%>
13
+ # Authentication Configuration
14
+ variable "user_pool_id" {
15
+ description = "Cognito User Pool ID for authentication"
16
+ type = string
17
+ }
18
+
19
+ variable "user_pool_client_ids" {
20
+ description = "List of Cognito User Pool Client IDs"
21
+ type = list(string)
22
+ }
23
+ <%_ } _%>
24
+
25
+ variable "env" {
26
+ description = "Environment variables for the Lambda function"
27
+ type = map(string)
28
+ default = {}
29
+ }
30
+
31
+ variable "additional_iam_policy_statements" {
32
+ description = "Additional IAM policy statements for the Lambda function"
33
+ type = list(object({
34
+ Effect = string
35
+ Action = list(string)
36
+ Resource = list(string)
37
+ }))
38
+ default = []
39
+ }
40
+
41
+ # CORS Configuration (passed to core module)
42
+ variable "cors_allow_credentials" {
43
+ description = "Whether to allow credentials in CORS requests"
44
+ type = bool
45
+ default = false
46
+ }
47
+
48
+ variable "cors_allow_headers" {
49
+ description = "List of allowed headers for CORS"
50
+ type = list(string)
51
+ default = ["authorization", "content-type", "x-amz-content-sha256", "x-amz-date", "x-amz-security-token"]
52
+ }
53
+
54
+ variable "cors_allow_methods" {
55
+ description = "List of allowed HTTP methods for CORS"
56
+ type = list(string)
57
+ default = ["*"]
58
+ }
59
+
60
+ variable "cors_allow_origins" {
61
+ description = "List of allowed origins for CORS"
62
+ type = list(string)
63
+ default = ["*"]
64
+ }
65
+
66
+ variable "cors_expose_headers" {
67
+ description = "List of headers to expose in CORS responses"
68
+ type = list(string)
69
+ default = []
70
+ }
71
+
72
+ variable "cors_max_age" {
73
+ description = "Maximum age for CORS preflight requests in seconds"
74
+ type = number
75
+ default = 0
76
+ }
77
+
78
+ # Tags
79
+ variable "tags" {
80
+ description = "Tags to apply to all resources"
81
+ type = map(string)
82
+ default = {}
83
+ }
84
+
85
+ # Get current AWS region and account ID
86
+ data "aws_region" "current" {}
87
+ data "aws_caller_identity" "current" {}
88
+
89
+ # Resources
90
+
91
+ # Create Lambda ZIP file from the bundle directory
92
+ data "archive_file" "lambda_zip" {
93
+ type = "zip"
94
+ source_dir = "${path.module}/../../../../../../../dist/<%- backend.dir %>/bundle"
95
+ output_path = "${path.module}/../../../../../../../dist/packages/common/terraform/apis/<%- apiNameKebabCase %>/lambda.zip"
96
+ }
97
+
98
+
99
+ # Use the core HTTP API module
100
+ module "http_api" {
101
+ source = "../../../core/api/http-api"
102
+
103
+ api_name = "<%- apiNameClassName %>"
104
+ api_description = "<%- apiNameClassName %> HTTP API"
105
+ stage_name = "$default"
106
+ stage_auto_deploy = true
107
+
108
+ # CORS Configuration
109
+ cors_allow_credentials = var.cors_allow_credentials
110
+ cors_allow_headers = var.cors_allow_headers
111
+ cors_allow_methods = var.cors_allow_methods
112
+ cors_allow_origins = var.cors_allow_origins
113
+ cors_expose_headers = var.cors_expose_headers
114
+ cors_max_age = var.cors_max_age
115
+
116
+ # Tags
117
+ tags = var.tags
118
+ }
119
+
120
+ # Lambda function
121
+ # This configures a single "router" lambda to serve all requests
122
+ resource "aws_lambda_function" "api_lambda" {
123
+ #checkov:skip=CKV_AWS_117:Lambda function does not need to be in VPC for this use case
124
+ #checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple API use case
125
+ #checkov:skip=CKV_AWS_272:Code signing not required for this use case
126
+ #checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
127
+ #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"
130
+ role = aws_iam_role.lambda_execution_role.arn
131
+ <%_ if (backend.type === 'trpc') { _%>
132
+ handler = "index.handler"
133
+ runtime = "nodejs22.x"
134
+ <%_ } else if (backend.type === 'fastapi') { _%>
135
+ handler = "<%= backend.moduleName %>.main.handler"
136
+ runtime = "python3.12"
137
+ <%_ } _%>
138
+ timeout = 30
139
+ memory_size = 128
140
+
141
+ source_code_hash = data.archive_file.lambda_zip.output_base64sha256
142
+
143
+ # Enable X-Ray tracing
144
+ tracing_config {
145
+ mode = "Active"
146
+ }
147
+
148
+ environment {
149
+ variables = merge({
150
+ AWS_CONNECTION_REUSE_ENABLED = "1"
151
+ }, var.env)
152
+ }
153
+
154
+ tags = var.tags
155
+ }
156
+
157
+ # IAM role for Lambda execution
158
+ resource "aws_iam_role" "lambda_execution_role" {
159
+ name = "<%- apiNameClassName %>Handler-execution-role"
160
+
161
+ assume_role_policy = jsonencode({
162
+ Version = "2012-10-17"
163
+ Statement = [
164
+ {
165
+ Action = "sts:AssumeRole"
166
+ Effect = "Allow"
167
+ Principal = {
168
+ Service = "lambda.amazonaws.com"
169
+ }
170
+ }
171
+ ]
172
+ })
173
+
174
+ tags = var.tags
175
+ }
176
+
177
+ # Attach basic execution policy to Lambda role
178
+ resource "aws_iam_role_policy_attachment" "lambda_basic_execution" {
179
+ policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
180
+ role = aws_iam_role.lambda_execution_role.name
181
+ }
182
+
183
+ # Attach X-Ray tracing policy to Lambda role
184
+ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
185
+ policy_arn = "arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess"
186
+ role = aws_iam_role.lambda_execution_role.name
187
+ }
188
+
189
+ # Additional IAM policies for Lambda (if provided)
190
+ resource "aws_iam_role_policy" "lambda_additional_policies" {
191
+ count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
192
+ name = "<%- apiNameClassName %>Handler-additional-policies"
193
+ role = aws_iam_role.lambda_execution_role.id
194
+
195
+ policy = jsonencode({
196
+ Version = "2012-10-17"
197
+ Statement = var.additional_iam_policy_statements
198
+ })
199
+ }
200
+
201
+ # CloudWatch Log Group for Lambda
202
+ resource "aws_cloudwatch_log_group" "lambda_logs" {
203
+ #checkov:skip=CKV_AWS_158:Using default CloudWatch log encryption
204
+ #checkov:skip=CKV_AWS_338:Log retention set to forever
205
+ #checkov:skip=CKV_AWS_66:Log retention set to forever
206
+ name = "/aws/lambda/<%- apiNameClassName %>Handler"
207
+ tags = var.tags
208
+ }
209
+
210
+ <%_ if (auth === 'Cognito') { _%>
211
+ # Cognito User Pool Authorizer
212
+ resource "aws_apigatewayv2_authorizer" "cognito_authorizer" {
213
+ api_id = module.http_api.api_id
214
+ authorizer_type = "JWT"
215
+ identity_sources = ["$request.header.Authorization"]
216
+ name = "<%- apiNameClassName %>Authorizer"
217
+
218
+ jwt_configuration {
219
+ audience = var.user_pool_client_ids
220
+ issuer = "https://cognito-idp.${data.aws_region.current.name}.amazonaws.com/${var.user_pool_id}"
221
+ }
222
+ }
223
+ <%_ } _%>
224
+
225
+ # Lambda integration for HTTP API
226
+ resource "aws_apigatewayv2_integration" "lambda_integration" {
227
+ api_id = module.http_api.api_id
228
+ integration_type = "AWS_PROXY"
229
+ integration_uri = aws_lambda_function.api_lambda.invoke_arn
230
+
231
+ payload_format_version = "2.0"
232
+ timeout_milliseconds = 30000
233
+
234
+ depends_on = [aws_lambda_function.api_lambda]
235
+ }
236
+
237
+ # Route for proxy integration (catches all requests)
238
+ resource "aws_apigatewayv2_route" "proxy_routes" {
239
+ # NB: OPTIONS is omitted here since API Gateway manages responding to preflight requests
240
+ # when cors settings are configured
241
+ for_each = toset(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"])
242
+
243
+ api_id = module.http_api.api_id
244
+ route_key = "${each.key} /{proxy+}"
245
+ target = "integrations/${aws_apigatewayv2_integration.lambda_integration.id}"
246
+
247
+ <%_ if (auth === 'IAM') { _%>
248
+ authorization_type = "AWS_IAM"
249
+ <%_ } else if (auth === 'Cognito') { _%>
250
+ authorization_type = "JWT"
251
+ authorizer_id = aws_apigatewayv2_authorizer.cognito_authorizer.id
252
+ <%_ } else if (auth === 'None') { _%>
253
+ # Note: you may wish to suppress the checkov rule CKV_AWS_309 if you are absolutely sure you
254
+ # need a public API without authentication
255
+ authorization_type = "NONE"
256
+ <%_ } _%>
257
+
258
+ depends_on = [aws_apigatewayv2_integration.lambda_integration<% if (auth === 'Cognito') { %>, aws_apigatewayv2_authorizer.cognito_authorizer<% } %>]
259
+ }
260
+
261
+ # Lambda permission for API Gateway to invoke the function
262
+ resource "aws_lambda_permission" "api_gateway_invoke" {
263
+ statement_id = "AllowExecutionFromAPIGateway"
264
+ action = "lambda:InvokeFunction"
265
+ function_name = aws_lambda_function.api_lambda.function_name
266
+ principal = "apigateway.amazonaws.com"
267
+ source_arn = "${module.http_api.api_execution_arn}/*/*"
268
+
269
+ depends_on = [module.http_api, aws_lambda_function.api_lambda]
270
+ }
271
+
272
+ # Outputs
273
+
274
+ # API Gateway Outputs (from core module)
275
+ output "api_id" {
276
+ description = "ID of the HTTP API Gateway"
277
+ value = module.http_api.api_id
278
+ }
279
+
280
+ output "api_arn" {
281
+ description = "ARN of the HTTP API Gateway"
282
+ value = module.http_api.api_arn
283
+ }
284
+
285
+ output "api_endpoint" {
286
+ description = "Base URL of the HTTP API Gateway"
287
+ value = module.http_api.api_endpoint
288
+ }
289
+
290
+ output "api_execution_arn" {
291
+ description = "Execution ARN of the HTTP API Gateway"
292
+ value = module.http_api.api_execution_arn
293
+ }
294
+
295
+ output "stage_invoke_url" {
296
+ description = "Invoke URL of the API Gateway stage"
297
+ value = module.http_api.stage_invoke_url
298
+ }
299
+
300
+ output "stage_arn" {
301
+ description = "ARN of the API Gateway stage"
302
+ value = module.http_api.stage_arn
303
+ }
304
+
305
+ output "stage_execution_arn" {
306
+ description = "Execution ARN of the API Gateway stage"
307
+ value = module.http_api.stage_execution_arn
308
+ }
309
+
310
+ # Lambda Function Outputs
311
+ output "lambda_function_name" {
312
+ description = "Name of the Lambda function"
313
+ value = aws_lambda_function.api_lambda.function_name
314
+ }
315
+
316
+ output "lambda_function_arn" {
317
+ description = "ARN of the Lambda function"
318
+ value = aws_lambda_function.api_lambda.arn
319
+ }
320
+
321
+ output "lambda_invoke_arn" {
322
+ description = "Invoke ARN of the Lambda function"
323
+ value = aws_lambda_function.api_lambda.invoke_arn
324
+ }
325
+
326
+ output "lambda_qualified_arn" {
327
+ description = "Qualified ARN of the Lambda function"
328
+ value = aws_lambda_function.api_lambda.qualified_arn
329
+ }
330
+
331
+ output "lambda_version" {
332
+ description = "Version of the Lambda function"
333
+ value = aws_lambda_function.api_lambda.version
334
+ }
335
+
336
+ output "lambda_source_code_hash" {
337
+ description = "Base64-encoded SHA256 hash of the Lambda deployment package"
338
+ value = aws_lambda_function.api_lambda.source_code_hash
339
+ }
340
+
341
+ output "lambda_source_code_size" {
342
+ description = "Size of the Lambda deployment package in bytes"
343
+ value = aws_lambda_function.api_lambda.source_code_size
344
+ }
345
+
346
+ # IAM Role Outputs
347
+ output "lambda_execution_role_arn" {
348
+ description = "ARN of the Lambda execution role"
349
+ value = aws_iam_role.lambda_execution_role.arn
350
+ }
351
+
352
+ output "lambda_execution_role_name" {
353
+ description = "Name of the Lambda execution role"
354
+ value = aws_iam_role.lambda_execution_role.name
355
+ }
356
+
357
+ # Integration Outputs
358
+ output "integration_id" {
359
+ description = "ID of the Lambda integration"
360
+ value = aws_apigatewayv2_integration.lambda_integration.id
361
+ }
362
+
363
+ # CloudWatch Log Groups
364
+ output "lambda_log_group_name" {
365
+ description = "Name of the Lambda CloudWatch log group"
366
+ value = aws_cloudwatch_log_group.lambda_logs.name
367
+ }
368
+
369
+ output "lambda_log_group_arn" {
370
+ description = "ARN of the Lambda CloudWatch log group"
371
+ value = aws_cloudwatch_log_group.lambda_logs.arn
372
+ }
373
+
374
+ output "api_log_group_name" {
375
+ description = "Name of the API Gateway CloudWatch log group"
376
+ value = module.http_api.api_log_group_name
377
+ }
378
+
379
+ output "api_log_group_arn" {
380
+ description = "ARN of the API Gateway CloudWatch log group"
381
+ value = module.http_api.api_log_group_arn
382
+ }