Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
changed variable type of vpc_config (#42)
Browse files Browse the repository at this point in the history
Terraform registry marked it as required but it's optional.
This is a drop-in replacement (patch version).
  • Loading branch information
moritzzimmer committed Oct 22, 2019
1 parent a78487d commit f87c1dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions modules/lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "aws_lambda_function" "lambda" {
timeout = var.timeout

dynamic "vpc_config" {
for_each = var.vpc_config == null ? [] : [var.vpc_config]
for_each = length(var.vpc_config) < 1 ? [] : [var.vpc_config]
content {
security_group_ids = vpc_config.value.security_group_ids
subnet_ids = vpc_config.value.subnet_ids
Expand Down Expand Up @@ -48,7 +48,7 @@ resource "aws_iam_role_policy_attachment" "cloudwatch_logs" {
}

resource "aws_iam_role_policy_attachment" "vpc_attachment" {
count = var.vpc_config == null ? 0 : 1
count = length(var.vpc_config) < 1 ? 0 : 1
role = aws_iam_role.lambda.name

// see https://docs.aws.amazon.com/lambda/latest/dg/vpc.html
Expand Down
7 changes: 2 additions & 5 deletions modules/lambda/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ variable "timeout" {

variable "vpc_config" {
description = "Provide this to allow your function to access your VPC (if both 'subnet_ids' and 'security_group_ids' are empty then vpc_config is considered to be empty or unset, see https://docs.aws.amazon.com/lambda/latest/dg/vpc.html for details)."
type = object({
security_group_ids = list(string)
subnet_ids = list(string)
})
default = null
type = map(list(string))
default = {}
}

7 changes: 2 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ variable "timeout" {

variable "vpc_config" {
description = "Provide this to allow your function to access your VPC (if both 'subnet_ids' and 'security_group_ids' are empty then vpc_config is considered to be empty or unset, see https://docs.aws.amazon.com/lambda/latest/dg/vpc.html for details)."
type = object({
security_group_ids = list(string)
subnet_ids = list(string)
})
default = null
type = map(list(string))
default = {}
}

0 comments on commit f87c1dd

Please sign in to comment.