Skip to content

Commit

Permalink
refactor(lambda): add vpc_config block only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mskrajnowski committed Mar 10, 2021
1 parent 46c2f69 commit a69fb11
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ resource "aws_lambda_function" "lambda" {
}
}

vpc_config {
subnet_ids = coalesce(var.subnet_ids, [])
security_group_ids = coalesce(var.security_group_ids, [])
dynamic "vpc_config" {
for_each = toset(var.subnet_ids != null || var.security_group_ids != null ? ["vpc_config"] : [])

content {
subnet_ids = coalesce(var.subnet_ids, [])
security_group_ids = coalesce(var.security_group_ids, [])
}
}

tags = var.tags
Expand Down

0 comments on commit a69fb11

Please sign in to comment.