Skip to content

Commit

Permalink
allow default sg by default
Browse files Browse the repository at this point in the history
  • Loading branch information
marciogoda committed Aug 12, 2024
1 parent b745cfb commit d40a79c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
locals {
security_group_ids = var.security_group_ids != null ? var.security_group_ids : [aws_security_group.default[0].id]
}

data "aws_security_group" "default" {
count = var.security_group_ids != null ? 0 : 1
name = "${terraform.workspace}-default-lambda-sg"
}


resource "aws_lambda_function" "lambda_function" {
image_uri = var.image_uri
s3_bucket = var.s3_bucket
Expand Down Expand Up @@ -25,7 +35,7 @@ resource "aws_lambda_function" "lambda_function" {

vpc_config {
subnet_ids = var.subnet_ids
security_group_ids = var.security_group_ids
security_group_ids = local.security_group_ids
}

environment {
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ variable "subnet_ids" {
variable "security_group_ids" {
type = list(string)
description = "The VPC security groups assigned to the Lambda."
default = []
default = null
}

variable "datadog_log_subscription_arn" {
Expand Down

0 comments on commit d40a79c

Please sign in to comment.