File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,7 @@ resource "aws_iam_role_policy_attachment" "lambda_policy_attach" {
224
224
}
225
225
226
226
resource "aws_security_group" "lambda_sg" {
227
+ count = var. lambda_vpc_config != null ? 1 : 0
227
228
name = " ${ local . long_name } -lambda-sg"
228
229
description = " Controls access to the Lambda"
229
230
vpc_id = var. vpc_id
@@ -255,9 +256,12 @@ resource "aws_lambda_function" "api_lambda" {
255
256
}
256
257
}
257
258
258
- vpc_config {
259
- subnet_ids = var. private_subnet_ids
260
- security_group_ids = concat ([aws_security_group . lambda_sg . id ], var. security_groups )
259
+ dynamic "vpc_config" {
260
+ for_each = var. lambda_vpc_config == null ? [] : [var . lambda_vpc_config ]
261
+ content {
262
+ subnet_ids = lambda_vpc_config. value . subnet_ids
263
+ security_group_ids = concat ([aws_security_group . lambda_sg . id ], lambda_vpc_config. value . security_group_ids )
264
+ }
261
265
}
262
266
}
263
267
You can’t perform that action at this time.
0 commit comments