Skip to content

Commit

Permalink
Add support for lambda layers (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
asafadar authored Aug 22, 2023
1 parent 39e77d1 commit 11e8af6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions modules/terraform-aws-alternat/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ resource "aws_lambda_function" "alternat_autoscaling_hook" {
timeout = var.lambda_timeout
role = aws_iam_role.nat_lambda_role.arn

layers = var.lambda_layer_arns

image_uri = var.lambda_package_type == "Image" ? "${var.alternat_image_uri}:${var.alternat_image_tag}" : null

runtime = var.lambda_package_type == "Zip" ? "python3.8" : null
Expand Down Expand Up @@ -127,6 +129,8 @@ resource "aws_lambda_function" "alternat_connectivity_tester" {
timeout = var.lambda_timeout
role = aws_iam_role.nat_lambda_role.arn

layers = var.lambda_layer_arns

image_uri = var.lambda_package_type == "Image" ? "${var.alternat_image_uri}:${var.alternat_image_tag}" : null

runtime = var.lambda_package_type == "Zip" ? "python3.8" : null
Expand Down
13 changes: 10 additions & 3 deletions modules/terraform-aws-alternat/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "additional_instance_policies" {
description = "Additional policies for the HA NAT instance IAM role."
type = list(object({
type = list(object({
policy_name = string
policy_json = string
}))
Expand Down Expand Up @@ -169,7 +169,7 @@ variable "tags" {

variable "vpc_az_maps" {
description = "A map of az to private route tables that the NAT instances will manage."
type = list(object({
type = list(object({
az = string
private_subnet_ids = list(string)
public_subnet_id = string
Expand Down Expand Up @@ -208,7 +208,7 @@ variable "lambda_timeout" {

variable "lambda_handlers" {
description = "Lambda handlers."
type = object({
type = object({
connectivity_tester = string,
alternat_autoscaling_hook = string,
})
Expand All @@ -235,3 +235,10 @@ variable "lambda_function_architectures" {
type = list(string)
default = ["x86_64"]
}

variable "lambda_layer_arns" {
type = list(string)
description = "List of Lambda layers ARN that will be added to functions"
default = null
}

0 comments on commit 11e8af6

Please sign in to comment.