Skip to content

Commit

Permalink
updating all sg and subnet variables
Browse files Browse the repository at this point in the history
  • Loading branch information
haitchison committed Dec 19, 2023
1 parent e99b9ef commit bbb7705
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
8 changes: 4 additions & 4 deletions test/unit-test/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
File renamed without changes.
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bbb7705

Please sign in to comment.