diff --git a/modules/terraform-aws-alternat/lambda.tf b/modules/terraform-aws-alternat/lambda.tf index 41432f6..48b8d0c 100644 --- a/modules/terraform-aws-alternat/lambda.tf +++ b/modules/terraform-aws-alternat/lambda.tf @@ -1,3 +1,12 @@ +locals { + autoscaling_func_env_vars = { + # Lambda function env vars cannot contain hyphens + for obj in var.vpc_az_maps + : replace(upper(obj.az), "-", "_") => join(",", obj.route_table_ids) + } + has_ipv6_env_var = { "HAS_IPV6" = var.lambda_has_ipv6 } +} + data "archive_file" "lambda" { count = var.lambda_package_type == "Zip" ? 1 : 0 type = "zip" @@ -36,15 +45,6 @@ resource "aws_lambda_function" "alternat_autoscaling_hook" { }, var.tags) } -locals { - autoscaling_func_env_vars = { - # Lambda function env vars cannot contain hyphens - for obj in var.vpc_az_maps - : replace(upper(obj.az), "-", "_") => join(",", obj.route_table_ids) - } - has_ipv6_env_var = { "HAS_IPV6" = var.lambda_has_ipv6 } -} - resource "aws_iam_role" "nat_lambda_role" { name = var.nat_lambda_function_role_name == "" ? null : var.nat_lambda_function_role_name name_prefix = var.nat_lambda_function_role_name == "" ? "alternat-lambda-role-" : null