@aws/nx-plugin 1.0.0-rc.31 → 1.0.0-rc.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +64 -3
- package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +280 -0
- package/src/open-api/ts-client/files/client.gen.ts.template +36 -1
- package/src/open-api/utils/normalise.js +13 -6
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.js +12 -1
- package/src/open-api/utils/parser.js.map +1 -1
- package/src/open-api/utils/types.d.ts +4 -1
- package/src/open-api/utils/types.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +414 -6
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +276 -4
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +414 -6
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +0 -23
- package/src/ts/mcp-server/generator.js +10 -22
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
- package/src/utils/versions.d.ts +5 -5
- package/src/utils/versions.js +4 -4
- package/src/utils/versions.js.map +1 -1
|
@@ -3426,6 +3426,30 @@ variable "asset_bucket_name" {
|
|
|
3426
3426
|
type = string
|
|
3427
3427
|
}
|
|
3428
3428
|
|
|
3429
|
+
# VPC Configuration (optional)
|
|
3430
|
+
variable "enable_vpc" {
|
|
3431
|
+
description = "Deploy the Lambda function into a VPC. Set alongside vpc_id/subnet_ids."
|
|
3432
|
+
type = bool
|
|
3433
|
+
default = false
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
variable "vpc_id" {
|
|
3437
|
+
description = "VPC ID to deploy the Lambda function into. Required when enable_vpc is true."
|
|
3438
|
+
type = string
|
|
3439
|
+
default = null
|
|
3440
|
+
|
|
3441
|
+
validation {
|
|
3442
|
+
condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
|
|
3443
|
+
error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
variable "subnet_ids" {
|
|
3448
|
+
description = "Subnet IDs to deploy the Lambda function into. Required when enable_vpc is true."
|
|
3449
|
+
type = list(string)
|
|
3450
|
+
default = null
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3429
3453
|
# CORS Configuration (passed to core module)
|
|
3430
3454
|
variable "cors_allow_credentials" {
|
|
3431
3455
|
description = "Whether to allow credentials in CORS requests"
|
|
@@ -3512,10 +3536,32 @@ module "http_api" {
|
|
|
3512
3536
|
tags = var.tags
|
|
3513
3537
|
}
|
|
3514
3538
|
|
|
3539
|
+
# Security group for the API Lambda function, used when deployed into a VPC
|
|
3540
|
+
resource "aws_security_group" "api_lambda" {
|
|
3541
|
+
count = var.enable_vpc ? 1 : 0
|
|
3542
|
+
|
|
3543
|
+
#checkov:skip=CKV2_AWS_5:Attached to api_lambda via vpc_config block; Checkov cannot resolve this reference
|
|
3544
|
+
name_prefix = "test-api-lambda-"
|
|
3545
|
+
description = "Security group for the TestApi API Lambda function"
|
|
3546
|
+
vpc_id = var.vpc_id
|
|
3547
|
+
tags = var.tags
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
resource "aws_vpc_security_group_egress_rule" "api_lambda_https" {
|
|
3551
|
+
count = var.enable_vpc ? 1 : 0
|
|
3552
|
+
|
|
3553
|
+
security_group_id = aws_security_group.api_lambda[0].id
|
|
3554
|
+
cidr_ipv4 = "0.0.0.0/0"
|
|
3555
|
+
from_port = 443
|
|
3556
|
+
to_port = 443
|
|
3557
|
+
ip_protocol = "tcp"
|
|
3558
|
+
description = "Allow outbound HTTPS to AWS service endpoints"
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3515
3561
|
# Lambda function
|
|
3516
3562
|
# This configures a single "router" lambda to serve all requests
|
|
3517
3563
|
resource "aws_lambda_function" "api_lambda" {
|
|
3518
|
-
#checkov:skip=CKV_AWS_117:Lambda function
|
|
3564
|
+
#checkov:skip=CKV_AWS_117:Lambda function is optionally deployed into a VPC via vpc_id/subnet_ids; not required for this use case
|
|
3519
3565
|
#checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple API use case
|
|
3520
3566
|
#checkov:skip=CKV_AWS_272:Code signing not required for this use case
|
|
3521
3567
|
#checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
|
|
@@ -3537,6 +3583,14 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
3537
3583
|
mode = "Active"
|
|
3538
3584
|
}
|
|
3539
3585
|
|
|
3586
|
+
dynamic "vpc_config" {
|
|
3587
|
+
for_each = var.enable_vpc ? [1] : []
|
|
3588
|
+
content {
|
|
3589
|
+
subnet_ids = var.subnet_ids
|
|
3590
|
+
security_group_ids = [aws_security_group.api_lambda[0].id]
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3540
3594
|
|
|
3541
3595
|
environment {
|
|
3542
3596
|
variables = merge({
|
|
@@ -3544,6 +3598,8 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
3544
3598
|
}
|
|
3545
3599
|
|
|
3546
3600
|
tags = var.tags
|
|
3601
|
+
|
|
3602
|
+
depends_on = [aws_iam_role_policy_attachment.lambda_vpc_access]
|
|
3547
3603
|
}
|
|
3548
3604
|
|
|
3549
3605
|
# IAM role for Lambda execution
|
|
@@ -3578,6 +3634,13 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
|
|
|
3578
3634
|
role = aws_iam_role.lambda_execution_role.name
|
|
3579
3635
|
}
|
|
3580
3636
|
|
|
3637
|
+
# Attach VPC access policy to Lambda role when deployed into a VPC
|
|
3638
|
+
resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
3639
|
+
count = var.enable_vpc ? 1 : 0
|
|
3640
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
|
|
3641
|
+
role = aws_iam_role.lambda_execution_role.name
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3581
3644
|
# Additional IAM policies for Lambda (if provided)
|
|
3582
3645
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
3583
3646
|
count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
|
|
@@ -3748,6 +3811,11 @@ output "lambda_execution_role_name" {
|
|
|
3748
3811
|
value = aws_iam_role.lambda_execution_role.name
|
|
3749
3812
|
}
|
|
3750
3813
|
|
|
3814
|
+
output "security_group_id" {
|
|
3815
|
+
description = "Security group ID of the API Lambda function, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
3816
|
+
value = var.enable_vpc ? aws_security_group.api_lambda[0].id : null
|
|
3817
|
+
}
|
|
3818
|
+
|
|
3751
3819
|
# Integration Outputs
|
|
3752
3820
|
output "integration_id" {
|
|
3753
3821
|
description = "ID of the Lambda integration"
|
|
@@ -4062,6 +4130,30 @@ variable "asset_bucket_name" {
|
|
|
4062
4130
|
type = string
|
|
4063
4131
|
}
|
|
4064
4132
|
|
|
4133
|
+
# VPC Configuration (optional)
|
|
4134
|
+
variable "enable_vpc" {
|
|
4135
|
+
description = "Deploy the Lambda function into a VPC. Set alongside vpc_id/subnet_ids."
|
|
4136
|
+
type = bool
|
|
4137
|
+
default = false
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
variable "vpc_id" {
|
|
4141
|
+
description = "VPC ID to deploy the Lambda function into. Required when enable_vpc is true."
|
|
4142
|
+
type = string
|
|
4143
|
+
default = null
|
|
4144
|
+
|
|
4145
|
+
validation {
|
|
4146
|
+
condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
|
|
4147
|
+
error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
variable "subnet_ids" {
|
|
4152
|
+
description = "Subnet IDs to deploy the Lambda function into. Required when enable_vpc is true."
|
|
4153
|
+
type = list(string)
|
|
4154
|
+
default = null
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4065
4157
|
# CORS Configuration (passed to core module)
|
|
4066
4158
|
variable "cors_allow_credentials" {
|
|
4067
4159
|
description = "Whether to allow credentials in CORS requests"
|
|
@@ -4148,10 +4240,32 @@ module "http_api" {
|
|
|
4148
4240
|
tags = var.tags
|
|
4149
4241
|
}
|
|
4150
4242
|
|
|
4243
|
+
# Security group for the API Lambda function, used when deployed into a VPC
|
|
4244
|
+
resource "aws_security_group" "api_lambda" {
|
|
4245
|
+
count = var.enable_vpc ? 1 : 0
|
|
4246
|
+
|
|
4247
|
+
#checkov:skip=CKV2_AWS_5:Attached to api_lambda via vpc_config block; Checkov cannot resolve this reference
|
|
4248
|
+
name_prefix = "test-api-lambda-"
|
|
4249
|
+
description = "Security group for the TestApi API Lambda function"
|
|
4250
|
+
vpc_id = var.vpc_id
|
|
4251
|
+
tags = var.tags
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
resource "aws_vpc_security_group_egress_rule" "api_lambda_https" {
|
|
4255
|
+
count = var.enable_vpc ? 1 : 0
|
|
4256
|
+
|
|
4257
|
+
security_group_id = aws_security_group.api_lambda[0].id
|
|
4258
|
+
cidr_ipv4 = "0.0.0.0/0"
|
|
4259
|
+
from_port = 443
|
|
4260
|
+
to_port = 443
|
|
4261
|
+
ip_protocol = "tcp"
|
|
4262
|
+
description = "Allow outbound HTTPS to AWS service endpoints"
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4151
4265
|
# Lambda function
|
|
4152
4266
|
# This configures a single "router" lambda to serve all requests
|
|
4153
4267
|
resource "aws_lambda_function" "api_lambda" {
|
|
4154
|
-
#checkov:skip=CKV_AWS_117:Lambda function
|
|
4268
|
+
#checkov:skip=CKV_AWS_117:Lambda function is optionally deployed into a VPC via vpc_id/subnet_ids; not required for this use case
|
|
4155
4269
|
#checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple API use case
|
|
4156
4270
|
#checkov:skip=CKV_AWS_272:Code signing not required for this use case
|
|
4157
4271
|
#checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
|
|
@@ -4173,6 +4287,14 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
4173
4287
|
mode = "Active"
|
|
4174
4288
|
}
|
|
4175
4289
|
|
|
4290
|
+
dynamic "vpc_config" {
|
|
4291
|
+
for_each = var.enable_vpc ? [1] : []
|
|
4292
|
+
content {
|
|
4293
|
+
subnet_ids = var.subnet_ids
|
|
4294
|
+
security_group_ids = [aws_security_group.api_lambda[0].id]
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4176
4298
|
|
|
4177
4299
|
environment {
|
|
4178
4300
|
variables = merge({
|
|
@@ -4180,6 +4302,8 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
4180
4302
|
}
|
|
4181
4303
|
|
|
4182
4304
|
tags = var.tags
|
|
4305
|
+
|
|
4306
|
+
depends_on = [aws_iam_role_policy_attachment.lambda_vpc_access]
|
|
4183
4307
|
}
|
|
4184
4308
|
|
|
4185
4309
|
# IAM role for Lambda execution
|
|
@@ -4214,6 +4338,13 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
|
|
|
4214
4338
|
role = aws_iam_role.lambda_execution_role.name
|
|
4215
4339
|
}
|
|
4216
4340
|
|
|
4341
|
+
# Attach VPC access policy to Lambda role when deployed into a VPC
|
|
4342
|
+
resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
4343
|
+
count = var.enable_vpc ? 1 : 0
|
|
4344
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
|
|
4345
|
+
role = aws_iam_role.lambda_execution_role.name
|
|
4346
|
+
}
|
|
4347
|
+
|
|
4217
4348
|
# Additional IAM policies for Lambda (if provided)
|
|
4218
4349
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
4219
4350
|
count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
|
|
@@ -4466,6 +4597,11 @@ output "lambda_execution_role_name" {
|
|
|
4466
4597
|
value = aws_iam_role.lambda_execution_role.name
|
|
4467
4598
|
}
|
|
4468
4599
|
|
|
4600
|
+
output "security_group_id" {
|
|
4601
|
+
description = "Security group ID of the API Lambda function, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
4602
|
+
value = var.enable_vpc ? aws_security_group.api_lambda[0].id : null
|
|
4603
|
+
}
|
|
4604
|
+
|
|
4469
4605
|
# Integration Outputs
|
|
4470
4606
|
output "integration_id" {
|
|
4471
4607
|
description = "ID of the Lambda integration"
|
|
@@ -4780,6 +4916,30 @@ variable "asset_bucket_name" {
|
|
|
4780
4916
|
type = string
|
|
4781
4917
|
}
|
|
4782
4918
|
|
|
4919
|
+
# VPC Configuration (optional)
|
|
4920
|
+
variable "enable_vpc" {
|
|
4921
|
+
description = "Deploy the Lambda function into a VPC. Set alongside vpc_id/subnet_ids."
|
|
4922
|
+
type = bool
|
|
4923
|
+
default = false
|
|
4924
|
+
}
|
|
4925
|
+
|
|
4926
|
+
variable "vpc_id" {
|
|
4927
|
+
description = "VPC ID to deploy the Lambda function into. Required when enable_vpc is true."
|
|
4928
|
+
type = string
|
|
4929
|
+
default = null
|
|
4930
|
+
|
|
4931
|
+
validation {
|
|
4932
|
+
condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
|
|
4933
|
+
error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
|
|
4937
|
+
variable "subnet_ids" {
|
|
4938
|
+
description = "Subnet IDs to deploy the Lambda function into. Required when enable_vpc is true."
|
|
4939
|
+
type = list(string)
|
|
4940
|
+
default = null
|
|
4941
|
+
}
|
|
4942
|
+
|
|
4783
4943
|
# CORS Configuration (passed to core module)
|
|
4784
4944
|
variable "cors_allow_credentials" {
|
|
4785
4945
|
description = "Whether to allow credentials in CORS requests"
|
|
@@ -4866,10 +5026,32 @@ module "http_api" {
|
|
|
4866
5026
|
tags = var.tags
|
|
4867
5027
|
}
|
|
4868
5028
|
|
|
5029
|
+
# Security group for the API Lambda function, used when deployed into a VPC
|
|
5030
|
+
resource "aws_security_group" "api_lambda" {
|
|
5031
|
+
count = var.enable_vpc ? 1 : 0
|
|
5032
|
+
|
|
5033
|
+
#checkov:skip=CKV2_AWS_5:Attached to api_lambda via vpc_config block; Checkov cannot resolve this reference
|
|
5034
|
+
name_prefix = "test-api-lambda-"
|
|
5035
|
+
description = "Security group for the TestApi API Lambda function"
|
|
5036
|
+
vpc_id = var.vpc_id
|
|
5037
|
+
tags = var.tags
|
|
5038
|
+
}
|
|
5039
|
+
|
|
5040
|
+
resource "aws_vpc_security_group_egress_rule" "api_lambda_https" {
|
|
5041
|
+
count = var.enable_vpc ? 1 : 0
|
|
5042
|
+
|
|
5043
|
+
security_group_id = aws_security_group.api_lambda[0].id
|
|
5044
|
+
cidr_ipv4 = "0.0.0.0/0"
|
|
5045
|
+
from_port = 443
|
|
5046
|
+
to_port = 443
|
|
5047
|
+
ip_protocol = "tcp"
|
|
5048
|
+
description = "Allow outbound HTTPS to AWS service endpoints"
|
|
5049
|
+
}
|
|
5050
|
+
|
|
4869
5051
|
# Lambda function
|
|
4870
5052
|
# This configures a single "router" lambda to serve all requests
|
|
4871
5053
|
resource "aws_lambda_function" "api_lambda" {
|
|
4872
|
-
#checkov:skip=CKV_AWS_117:Lambda function
|
|
5054
|
+
#checkov:skip=CKV_AWS_117:Lambda function is optionally deployed into a VPC via vpc_id/subnet_ids; not required for this use case
|
|
4873
5055
|
#checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple API use case
|
|
4874
5056
|
#checkov:skip=CKV_AWS_272:Code signing not required for this use case
|
|
4875
5057
|
#checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
|
|
@@ -4891,6 +5073,14 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
4891
5073
|
mode = "Active"
|
|
4892
5074
|
}
|
|
4893
5075
|
|
|
5076
|
+
dynamic "vpc_config" {
|
|
5077
|
+
for_each = var.enable_vpc ? [1] : []
|
|
5078
|
+
content {
|
|
5079
|
+
subnet_ids = var.subnet_ids
|
|
5080
|
+
security_group_ids = [aws_security_group.api_lambda[0].id]
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5083
|
+
|
|
4894
5084
|
|
|
4895
5085
|
environment {
|
|
4896
5086
|
variables = merge({
|
|
@@ -4898,6 +5088,8 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
4898
5088
|
}
|
|
4899
5089
|
|
|
4900
5090
|
tags = var.tags
|
|
5091
|
+
|
|
5092
|
+
depends_on = [aws_iam_role_policy_attachment.lambda_vpc_access]
|
|
4901
5093
|
}
|
|
4902
5094
|
|
|
4903
5095
|
# IAM role for Lambda execution
|
|
@@ -4932,6 +5124,13 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
|
|
|
4932
5124
|
role = aws_iam_role.lambda_execution_role.name
|
|
4933
5125
|
}
|
|
4934
5126
|
|
|
5127
|
+
# Attach VPC access policy to Lambda role when deployed into a VPC
|
|
5128
|
+
resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
5129
|
+
count = var.enable_vpc ? 1 : 0
|
|
5130
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
|
|
5131
|
+
role = aws_iam_role.lambda_execution_role.name
|
|
5132
|
+
}
|
|
5133
|
+
|
|
4935
5134
|
# Additional IAM policies for Lambda (if provided)
|
|
4936
5135
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
4937
5136
|
count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
|
|
@@ -5089,6 +5288,11 @@ output "lambda_execution_role_name" {
|
|
|
5089
5288
|
value = aws_iam_role.lambda_execution_role.name
|
|
5090
5289
|
}
|
|
5091
5290
|
|
|
5291
|
+
output "security_group_id" {
|
|
5292
|
+
description = "Security group ID of the API Lambda function, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
5293
|
+
value = var.enable_vpc ? aws_security_group.api_lambda[0].id : null
|
|
5294
|
+
}
|
|
5295
|
+
|
|
5092
5296
|
# Integration Outputs
|
|
5093
5297
|
output "integration_id" {
|
|
5094
5298
|
description = "ID of the Lambda integration"
|
|
@@ -5422,6 +5626,30 @@ variable "asset_bucket_name" {
|
|
|
5422
5626
|
type = string
|
|
5423
5627
|
}
|
|
5424
5628
|
|
|
5629
|
+
# VPC Configuration (optional)
|
|
5630
|
+
variable "enable_vpc" {
|
|
5631
|
+
description = "Deploy the Lambda function into a VPC. Set alongside vpc_id/subnet_ids."
|
|
5632
|
+
type = bool
|
|
5633
|
+
default = false
|
|
5634
|
+
}
|
|
5635
|
+
|
|
5636
|
+
variable "vpc_id" {
|
|
5637
|
+
description = "VPC ID to deploy the Lambda function into. Required when enable_vpc is true."
|
|
5638
|
+
type = string
|
|
5639
|
+
default = null
|
|
5640
|
+
|
|
5641
|
+
validation {
|
|
5642
|
+
condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
|
|
5643
|
+
error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
|
|
5644
|
+
}
|
|
5645
|
+
}
|
|
5646
|
+
|
|
5647
|
+
variable "subnet_ids" {
|
|
5648
|
+
description = "Subnet IDs to deploy the Lambda function into. Required when enable_vpc is true."
|
|
5649
|
+
type = list(string)
|
|
5650
|
+
default = null
|
|
5651
|
+
}
|
|
5652
|
+
|
|
5425
5653
|
# CORS Configuration (passed to core module)
|
|
5426
5654
|
|
|
5427
5655
|
variable "cors_allow_headers" {
|
|
@@ -5518,9 +5746,31 @@ resource "aws_wafv2_web_acl_association" "api_waf_association" {
|
|
|
5518
5746
|
depends_on = [aws_api_gateway_stage.api_stage]
|
|
5519
5747
|
}
|
|
5520
5748
|
|
|
5749
|
+
# Security group for the API Lambda function, used when deployed into a VPC
|
|
5750
|
+
resource "aws_security_group" "api_lambda" {
|
|
5751
|
+
count = var.enable_vpc ? 1 : 0
|
|
5752
|
+
|
|
5753
|
+
#checkov:skip=CKV2_AWS_5:Attached to api_lambda via vpc_config block; Checkov cannot resolve this reference
|
|
5754
|
+
name_prefix = "test-api-lambda-"
|
|
5755
|
+
description = "Security group for the TestApi API Lambda function"
|
|
5756
|
+
vpc_id = var.vpc_id
|
|
5757
|
+
tags = var.tags
|
|
5758
|
+
}
|
|
5759
|
+
|
|
5760
|
+
resource "aws_vpc_security_group_egress_rule" "api_lambda_https" {
|
|
5761
|
+
count = var.enable_vpc ? 1 : 0
|
|
5762
|
+
|
|
5763
|
+
security_group_id = aws_security_group.api_lambda[0].id
|
|
5764
|
+
cidr_ipv4 = "0.0.0.0/0"
|
|
5765
|
+
from_port = 443
|
|
5766
|
+
to_port = 443
|
|
5767
|
+
ip_protocol = "tcp"
|
|
5768
|
+
description = "Allow outbound HTTPS to AWS service endpoints"
|
|
5769
|
+
}
|
|
5770
|
+
|
|
5521
5771
|
# Lambda function
|
|
5522
5772
|
resource "aws_lambda_function" "api_lambda" {
|
|
5523
|
-
#checkov:skip=CKV_AWS_117:Lambda function
|
|
5773
|
+
#checkov:skip=CKV_AWS_117:Lambda function is optionally deployed into a VPC via vpc_id/subnet_ids; not required for this use case
|
|
5524
5774
|
#checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple API use case
|
|
5525
5775
|
#checkov:skip=CKV_AWS_272:Code signing not required for this use case
|
|
5526
5776
|
#checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
|
|
@@ -5542,6 +5792,14 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
5542
5792
|
mode = "Active"
|
|
5543
5793
|
}
|
|
5544
5794
|
|
|
5795
|
+
dynamic "vpc_config" {
|
|
5796
|
+
for_each = var.enable_vpc ? [1] : []
|
|
5797
|
+
content {
|
|
5798
|
+
subnet_ids = var.subnet_ids
|
|
5799
|
+
security_group_ids = [aws_security_group.api_lambda[0].id]
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5802
|
+
|
|
5545
5803
|
|
|
5546
5804
|
environment {
|
|
5547
5805
|
variables = merge({
|
|
@@ -5549,6 +5807,8 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
5549
5807
|
}
|
|
5550
5808
|
|
|
5551
5809
|
tags = var.tags
|
|
5810
|
+
|
|
5811
|
+
depends_on = [aws_iam_role_policy_attachment.lambda_vpc_access]
|
|
5552
5812
|
}
|
|
5553
5813
|
|
|
5554
5814
|
# IAM role for Lambda execution
|
|
@@ -5583,6 +5843,13 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
|
|
|
5583
5843
|
role = aws_iam_role.lambda_execution_role.name
|
|
5584
5844
|
}
|
|
5585
5845
|
|
|
5846
|
+
# Attach VPC access policy to Lambda role when deployed into a VPC
|
|
5847
|
+
resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
5848
|
+
count = var.enable_vpc ? 1 : 0
|
|
5849
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
|
|
5850
|
+
role = aws_iam_role.lambda_execution_role.name
|
|
5851
|
+
}
|
|
5852
|
+
|
|
5586
5853
|
# Additional IAM policies for Lambda (if provided)
|
|
5587
5854
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
5588
5855
|
count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
|
|
@@ -5968,6 +6235,11 @@ output "lambda_execution_role_name" {
|
|
|
5968
6235
|
value = aws_iam_role.lambda_execution_role.name
|
|
5969
6236
|
}
|
|
5970
6237
|
|
|
6238
|
+
output "security_group_id" {
|
|
6239
|
+
description = "Security group ID of the API Lambda function, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
6240
|
+
value = var.enable_vpc ? aws_security_group.api_lambda[0].id : null
|
|
6241
|
+
}
|
|
6242
|
+
|
|
5971
6243
|
# Integration Outputs
|
|
5972
6244
|
output "integration_id" {
|
|
5973
6245
|
description = "ID of the Lambda integration"
|
|
@@ -6292,6 +6564,30 @@ variable "asset_bucket_name" {
|
|
|
6292
6564
|
type = string
|
|
6293
6565
|
}
|
|
6294
6566
|
|
|
6567
|
+
# VPC Configuration (optional)
|
|
6568
|
+
variable "enable_vpc" {
|
|
6569
|
+
description = "Deploy the Lambda function into a VPC. Set alongside vpc_id/subnet_ids."
|
|
6570
|
+
type = bool
|
|
6571
|
+
default = false
|
|
6572
|
+
}
|
|
6573
|
+
|
|
6574
|
+
variable "vpc_id" {
|
|
6575
|
+
description = "VPC ID to deploy the Lambda function into. Required when enable_vpc is true."
|
|
6576
|
+
type = string
|
|
6577
|
+
default = null
|
|
6578
|
+
|
|
6579
|
+
validation {
|
|
6580
|
+
condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
|
|
6581
|
+
error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
|
|
6582
|
+
}
|
|
6583
|
+
}
|
|
6584
|
+
|
|
6585
|
+
variable "subnet_ids" {
|
|
6586
|
+
description = "Subnet IDs to deploy the Lambda function into. Required when enable_vpc is true."
|
|
6587
|
+
type = list(string)
|
|
6588
|
+
default = null
|
|
6589
|
+
}
|
|
6590
|
+
|
|
6295
6591
|
# CORS Configuration (passed to core module)
|
|
6296
6592
|
|
|
6297
6593
|
variable "cors_allow_headers" {
|
|
@@ -6388,9 +6684,31 @@ resource "aws_wafv2_web_acl_association" "api_waf_association" {
|
|
|
6388
6684
|
depends_on = [aws_api_gateway_stage.api_stage]
|
|
6389
6685
|
}
|
|
6390
6686
|
|
|
6687
|
+
# Security group for the API Lambda function, used when deployed into a VPC
|
|
6688
|
+
resource "aws_security_group" "api_lambda" {
|
|
6689
|
+
count = var.enable_vpc ? 1 : 0
|
|
6690
|
+
|
|
6691
|
+
#checkov:skip=CKV2_AWS_5:Attached to api_lambda via vpc_config block; Checkov cannot resolve this reference
|
|
6692
|
+
name_prefix = "test-api-lambda-"
|
|
6693
|
+
description = "Security group for the TestApi API Lambda function"
|
|
6694
|
+
vpc_id = var.vpc_id
|
|
6695
|
+
tags = var.tags
|
|
6696
|
+
}
|
|
6697
|
+
|
|
6698
|
+
resource "aws_vpc_security_group_egress_rule" "api_lambda_https" {
|
|
6699
|
+
count = var.enable_vpc ? 1 : 0
|
|
6700
|
+
|
|
6701
|
+
security_group_id = aws_security_group.api_lambda[0].id
|
|
6702
|
+
cidr_ipv4 = "0.0.0.0/0"
|
|
6703
|
+
from_port = 443
|
|
6704
|
+
to_port = 443
|
|
6705
|
+
ip_protocol = "tcp"
|
|
6706
|
+
description = "Allow outbound HTTPS to AWS service endpoints"
|
|
6707
|
+
}
|
|
6708
|
+
|
|
6391
6709
|
# Lambda function
|
|
6392
6710
|
resource "aws_lambda_function" "api_lambda" {
|
|
6393
|
-
#checkov:skip=CKV_AWS_117:Lambda function
|
|
6711
|
+
#checkov:skip=CKV_AWS_117:Lambda function is optionally deployed into a VPC via vpc_id/subnet_ids; not required for this use case
|
|
6394
6712
|
#checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple API use case
|
|
6395
6713
|
#checkov:skip=CKV_AWS_272:Code signing not required for this use case
|
|
6396
6714
|
#checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
|
|
@@ -6412,6 +6730,14 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
6412
6730
|
mode = "Active"
|
|
6413
6731
|
}
|
|
6414
6732
|
|
|
6733
|
+
dynamic "vpc_config" {
|
|
6734
|
+
for_each = var.enable_vpc ? [1] : []
|
|
6735
|
+
content {
|
|
6736
|
+
subnet_ids = var.subnet_ids
|
|
6737
|
+
security_group_ids = [aws_security_group.api_lambda[0].id]
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
|
|
6415
6741
|
|
|
6416
6742
|
environment {
|
|
6417
6743
|
variables = merge({
|
|
@@ -6419,6 +6745,8 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
6419
6745
|
}
|
|
6420
6746
|
|
|
6421
6747
|
tags = var.tags
|
|
6748
|
+
|
|
6749
|
+
depends_on = [aws_iam_role_policy_attachment.lambda_vpc_access]
|
|
6422
6750
|
}
|
|
6423
6751
|
|
|
6424
6752
|
# IAM role for Lambda execution
|
|
@@ -6453,6 +6781,13 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
|
|
|
6453
6781
|
role = aws_iam_role.lambda_execution_role.name
|
|
6454
6782
|
}
|
|
6455
6783
|
|
|
6784
|
+
# Attach VPC access policy to Lambda role when deployed into a VPC
|
|
6785
|
+
resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
6786
|
+
count = var.enable_vpc ? 1 : 0
|
|
6787
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
|
|
6788
|
+
role = aws_iam_role.lambda_execution_role.name
|
|
6789
|
+
}
|
|
6790
|
+
|
|
6456
6791
|
# Additional IAM policies for Lambda (if provided)
|
|
6457
6792
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
6458
6793
|
count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
|
|
@@ -6837,6 +7172,11 @@ output "lambda_execution_role_name" {
|
|
|
6837
7172
|
value = aws_iam_role.lambda_execution_role.name
|
|
6838
7173
|
}
|
|
6839
7174
|
|
|
7175
|
+
output "security_group_id" {
|
|
7176
|
+
description = "Security group ID of the API Lambda function, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
7177
|
+
value = var.enable_vpc ? aws_security_group.api_lambda[0].id : null
|
|
7178
|
+
}
|
|
7179
|
+
|
|
6840
7180
|
# Integration Outputs
|
|
6841
7181
|
output "integration_id" {
|
|
6842
7182
|
description = "ID of the Lambda integration"
|
|
@@ -7161,6 +7501,30 @@ variable "asset_bucket_name" {
|
|
|
7161
7501
|
type = string
|
|
7162
7502
|
}
|
|
7163
7503
|
|
|
7504
|
+
# VPC Configuration (optional)
|
|
7505
|
+
variable "enable_vpc" {
|
|
7506
|
+
description = "Deploy the Lambda function into a VPC. Set alongside vpc_id/subnet_ids."
|
|
7507
|
+
type = bool
|
|
7508
|
+
default = false
|
|
7509
|
+
}
|
|
7510
|
+
|
|
7511
|
+
variable "vpc_id" {
|
|
7512
|
+
description = "VPC ID to deploy the Lambda function into. Required when enable_vpc is true."
|
|
7513
|
+
type = string
|
|
7514
|
+
default = null
|
|
7515
|
+
|
|
7516
|
+
validation {
|
|
7517
|
+
condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
|
|
7518
|
+
error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
|
|
7519
|
+
}
|
|
7520
|
+
}
|
|
7521
|
+
|
|
7522
|
+
variable "subnet_ids" {
|
|
7523
|
+
description = "Subnet IDs to deploy the Lambda function into. Required when enable_vpc is true."
|
|
7524
|
+
type = list(string)
|
|
7525
|
+
default = null
|
|
7526
|
+
}
|
|
7527
|
+
|
|
7164
7528
|
# CORS Configuration (passed to core module)
|
|
7165
7529
|
|
|
7166
7530
|
variable "cors_allow_headers" {
|
|
@@ -7257,9 +7621,31 @@ resource "aws_wafv2_web_acl_association" "api_waf_association" {
|
|
|
7257
7621
|
depends_on = [aws_api_gateway_stage.api_stage]
|
|
7258
7622
|
}
|
|
7259
7623
|
|
|
7624
|
+
# Security group for the API Lambda function, used when deployed into a VPC
|
|
7625
|
+
resource "aws_security_group" "api_lambda" {
|
|
7626
|
+
count = var.enable_vpc ? 1 : 0
|
|
7627
|
+
|
|
7628
|
+
#checkov:skip=CKV2_AWS_5:Attached to api_lambda via vpc_config block; Checkov cannot resolve this reference
|
|
7629
|
+
name_prefix = "test-api-lambda-"
|
|
7630
|
+
description = "Security group for the TestApi API Lambda function"
|
|
7631
|
+
vpc_id = var.vpc_id
|
|
7632
|
+
tags = var.tags
|
|
7633
|
+
}
|
|
7634
|
+
|
|
7635
|
+
resource "aws_vpc_security_group_egress_rule" "api_lambda_https" {
|
|
7636
|
+
count = var.enable_vpc ? 1 : 0
|
|
7637
|
+
|
|
7638
|
+
security_group_id = aws_security_group.api_lambda[0].id
|
|
7639
|
+
cidr_ipv4 = "0.0.0.0/0"
|
|
7640
|
+
from_port = 443
|
|
7641
|
+
to_port = 443
|
|
7642
|
+
ip_protocol = "tcp"
|
|
7643
|
+
description = "Allow outbound HTTPS to AWS service endpoints"
|
|
7644
|
+
}
|
|
7645
|
+
|
|
7260
7646
|
# Lambda function
|
|
7261
7647
|
resource "aws_lambda_function" "api_lambda" {
|
|
7262
|
-
#checkov:skip=CKV_AWS_117:Lambda function
|
|
7648
|
+
#checkov:skip=CKV_AWS_117:Lambda function is optionally deployed into a VPC via vpc_id/subnet_ids; not required for this use case
|
|
7263
7649
|
#checkov:skip=CKV_AWS_116:Dead Letter Queue not required for this simple API use case
|
|
7264
7650
|
#checkov:skip=CKV_AWS_272:Code signing not required for this use case
|
|
7265
7651
|
#checkov:skip=CKV_AWS_115:Concurrent execution limit not required for this use case
|
|
@@ -7281,6 +7667,14 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
7281
7667
|
mode = "Active"
|
|
7282
7668
|
}
|
|
7283
7669
|
|
|
7670
|
+
dynamic "vpc_config" {
|
|
7671
|
+
for_each = var.enable_vpc ? [1] : []
|
|
7672
|
+
content {
|
|
7673
|
+
subnet_ids = var.subnet_ids
|
|
7674
|
+
security_group_ids = [aws_security_group.api_lambda[0].id]
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
|
|
7284
7678
|
|
|
7285
7679
|
environment {
|
|
7286
7680
|
variables = merge({
|
|
@@ -7288,6 +7682,8 @@ resource "aws_lambda_function" "api_lambda" {
|
|
|
7288
7682
|
}
|
|
7289
7683
|
|
|
7290
7684
|
tags = var.tags
|
|
7685
|
+
|
|
7686
|
+
depends_on = [aws_iam_role_policy_attachment.lambda_vpc_access]
|
|
7291
7687
|
}
|
|
7292
7688
|
|
|
7293
7689
|
# IAM role for Lambda execution
|
|
@@ -7322,6 +7718,13 @@ resource "aws_iam_role_policy_attachment" "lambda_xray_execution" {
|
|
|
7322
7718
|
role = aws_iam_role.lambda_execution_role.name
|
|
7323
7719
|
}
|
|
7324
7720
|
|
|
7721
|
+
# Attach VPC access policy to Lambda role when deployed into a VPC
|
|
7722
|
+
resource "aws_iam_role_policy_attachment" "lambda_vpc_access" {
|
|
7723
|
+
count = var.enable_vpc ? 1 : 0
|
|
7724
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
|
|
7725
|
+
role = aws_iam_role.lambda_execution_role.name
|
|
7726
|
+
}
|
|
7727
|
+
|
|
7325
7728
|
# Additional IAM policies for Lambda (if provided)
|
|
7326
7729
|
resource "aws_iam_role_policy" "lambda_additional_policies" {
|
|
7327
7730
|
count = length(var.additional_iam_policy_statements) > 0 ? 1 : 0
|
|
@@ -7789,6 +8192,11 @@ output "lambda_execution_role_name" {
|
|
|
7789
8192
|
value = aws_iam_role.lambda_execution_role.name
|
|
7790
8193
|
}
|
|
7791
8194
|
|
|
8195
|
+
output "security_group_id" {
|
|
8196
|
+
description = "Security group ID of the API Lambda function, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
8197
|
+
value = var.enable_vpc ? aws_security_group.api_lambda[0].id : null
|
|
8198
|
+
}
|
|
8199
|
+
|
|
7792
8200
|
# Integration Outputs
|
|
7793
8201
|
output "integration_id" {
|
|
7794
8202
|
description = "ID of the Lambda integration"
|
|
@@ -787,26 +787,3 @@ void (async () => {
|
|
|
787
787
|
})();
|
|
788
788
|
"
|
|
789
789
|
`;
|
|
790
|
-
|
|
791
|
-
exports[`ts#mcp-server generator > should match snapshot for generated files > updated-package.json 1`] = `
|
|
792
|
-
"{
|
|
793
|
-
"name": "test-project",
|
|
794
|
-
"version": "1.0.0",
|
|
795
|
-
"bin": {
|
|
796
|
-
"snapshot-server": "./src/snapshot-server/stdio.js"
|
|
797
|
-
},
|
|
798
|
-
"dependencies": {
|
|
799
|
-
"@aws-lambda-powertools/parameters": "2.33.1",
|
|
800
|
-
"@aws-sdk/client-appconfigdata": "3.1075.0",
|
|
801
|
-
"@modelcontextprotocol/sdk": "1.29.0",
|
|
802
|
-
"express": "5.2.1",
|
|
803
|
-
"zod": "4.4.3"
|
|
804
|
-
},
|
|
805
|
-
"devDependencies": {
|
|
806
|
-
"@modelcontextprotocol/inspector": "0.19.0",
|
|
807
|
-
"@types/express": "5.0.6",
|
|
808
|
-
"tsx": "4.22.4"
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
"
|
|
812
|
-
`;
|