From bbb7705dd9be0e2ef70d05224e185a3d4443d352 Mon Sep 17 00:00:00 2001 From: Hope Aitchison Date: Tue, 19 Dec 2023 11:43:25 +0000 Subject: [PATCH] updating all sg and subnet variables --- main.tf | 6 +++--- test/unit-test/main.tf | 4 ++-- test/unit-test/outputs.tf | 8 ++++---- test/unit-test/{test-lambda => test}/test.py | 0 variables.tf | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) rename test/unit-test/{test-lambda => test}/test.py (100%) diff --git a/main.tf b/main.tf index f8e0bcd..370c071 100644 --- a/main.tf +++ b/main.tf @@ -85,10 +85,10 @@ resource "aws_lambda_function" "this" { #tfsec:ignore:aws-lambda-enable-tracing } } dynamic "vpc_config" { - for_each = var.subnet_ids != null && var.security_group_ids != null ? [true] : [] + for_each = var.vpc_subnet_ids != null && var.vpc_security_group_ids != null ? [true] : [] content { - security_group_ids = var.security_group_ids - subnet_ids = var.subnet_ids + security_group_ids = var.vpc_security_group_ids + subnet_ids = var.vpc_subnet_ids } } } diff --git a/test/unit-test/main.tf b/test/unit-test/main.tf index 14ac379..2b82481 100644 --- a/test/unit-test/main.tf +++ b/test/unit-test/main.tf @@ -44,8 +44,8 @@ module "lambda_function_in_vpc" { policy_json_attached = true policy_json = data.aws_iam_policy_document.instance-scheduler-lambda-function-policy.json - subnet_ids = aws_subnet.lambda_subnet_test.id - security_group_ids = aws_security_group.lambda_security_group_test.id + vpc_subnet_ids = [aws_subnet.lambda_subnet_test.id] + vpc_security_group_ids = [aws_security_group.lambda_security_group_test.id] } resource "aws_cloudwatch_event_rule" "instance_scheduler_weekly_stop_at_night" { diff --git a/test/unit-test/outputs.tf b/test/unit-test/outputs.tf index 32ea98e..52955ce 100644 --- a/test/unit-test/outputs.tf +++ b/test/unit-test/outputs.tf @@ -10,10 +10,10 @@ output "result_code" { value = jsondecode(aws_lambda_invocation.test_invocation.result)["statusCode"] } -output "security_group_id" { - value = module.lambda_function_in_vpc.security_group_ids +output "vpc_security_group_ids" { + value = module.lambda_function_in_vpc.vpc_security_group_ids } -output "subnet_id" { - value = module.lambda_function_in_vpc.subnet_ids +output "vpc_subnet_ids" { + value = module.lambda_function_in_vpc.vpc_subnet_ids } \ No newline at end of file diff --git a/test/unit-test/test-lambda/test.py b/test/unit-test/test/test.py similarity index 100% rename from test/unit-test/test-lambda/test.py rename to test/unit-test/test/test.py diff --git a/variables.tf b/variables.tf index ecfc1db..1766e10 100644 --- a/variables.tf +++ b/variables.tf @@ -151,13 +151,13 @@ variable "sns_topic_on_success" { default = "" } -variable "subnet_ids" { +variable "vpc_subnet_ids" { description = "List of subnet ids when Lambda Function should run in the VPC. Usually private or intra subnets." type = list(string) default = null } -variable "security_group_ids" { +variable "vpc_security_group_ids" { description = "List of security group ids when Lambda Function should run in the VPC." type = list(string) default = null