From f87c1dde57c63af531e677e491c7fa508d6aac9e Mon Sep 17 00:00:00 2001 From: Moritz Zimmer Date: Tue, 22 Oct 2019 16:40:03 +0200 Subject: [PATCH] changed variable type of vpc_config (#42) Terraform registry marked it as required but it's optional. This is a drop-in replacement (patch version). --- modules/lambda/main.tf | 4 ++-- modules/lambda/variables.tf | 7 ++----- variables.tf | 7 ++----- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/modules/lambda/main.tf b/modules/lambda/main.tf index 930a55d..f1e2786 100644 --- a/modules/lambda/main.tf +++ b/modules/lambda/main.tf @@ -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 @@ -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 diff --git a/modules/lambda/variables.tf b/modules/lambda/variables.tf index ba6d6f0..138a20a 100644 --- a/modules/lambda/variables.tf +++ b/modules/lambda/variables.tf @@ -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 = {} } diff --git a/variables.tf b/variables.tf index 45ebfb8..c0203e0 100644 --- a/variables.tf +++ b/variables.tf @@ -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 = {} }