From 10e967ed47d31d6dc39af0d1df576a79955438f3 Mon Sep 17 00:00:00 2001 From: Marcio Goda Date: Wed, 21 Aug 2024 15:40:41 +0100 Subject: [PATCH] add use_default_security_group --- main.tf | 3 ++- variables.tf | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index f2ffd32..38f0a1a 100644 --- a/main.tf +++ b/main.tf @@ -1,10 +1,11 @@ locals { - security_group_ids = var.use_default_sg == true ? [data.aws_security_group.default[0].id] : var.security_group_ids + security_group_ids = var.use_default_security_group == true ? [data.aws_security_group.default[0].id] : var.security_group_ids } data "aws_security_group" "default" { count = var.use_default_sg == true ? 1 : 0 name = "${terraform.workspace}-default-lambda-sg" + vpc_id = var.vpc_id } resource "aws_lambda_function" "lambda_function" { s3_bucket = var.s3_bucket diff --git a/variables.tf b/variables.tf index ecff4b0..276039d 100644 --- a/variables.tf +++ b/variables.tf @@ -108,4 +108,15 @@ variable "architectures" { variable "use_default_sg" { description = "Whether to use the default security group for the Lambda function." default = false +} + +variable "vpc_id" { + description = "The VPC ID in which the Lambda runs" + default = "" +} + +variable "use_default_security_group" { + type = bool + description = "Whether to use the default security group for the Lambda function." + default = false } \ No newline at end of file