diff --git a/anti-virus-scan.tf b/anti-virus-scan.tf index afb60b7..19fce09 100644 --- a/anti-virus-scan.tf +++ b/anti-virus-scan.tf @@ -164,7 +164,7 @@ resource "aws_lambda_function" "main_scan" { description = "Scans s3 objects with clamav for viruses." s3_bucket = var.lambda_s3_bucket - s3_key = var.lambda_package_key + s3_key = local.lambda_package_key function_name = var.name_scan role = aws_iam_role.main_scan.arn diff --git a/anti-virus-update.tf b/anti-virus-update.tf index 72a97c5..a09ad08 100644 --- a/anti-virus-update.tf +++ b/anti-virus-update.tf @@ -123,7 +123,7 @@ resource "aws_lambda_function" "main_update" { description = "Updates clamav definitions stored in s3." s3_bucket = var.lambda_s3_bucket - s3_key = var.lambda_package_key + s3_key = local.lambda_package_key function_name = var.name_update role = aws_iam_role.main_update.arn diff --git a/main.tf b/main.tf index be3d1f4..ba7c599 100644 --- a/main.tf +++ b/main.tf @@ -6,3 +6,7 @@ data "aws_caller_identity" "current" {} # The AWS partition (commercial or govcloud) data "aws_partition" "current" {} + +locals { + lambda_package_key = var.lambda_package_key != null ? var.lambda_package_key : "${var.lambda_package}/${var.lambda_version}/${var.lambda_package}.zip" +} diff --git a/variables.tf b/variables.tf index 1f7175b..fd46a9f 100644 --- a/variables.tf +++ b/variables.tf @@ -21,10 +21,20 @@ variable "lambda_s3_bucket" { type = string } +variable "lambda_version" { + description = "The version the Lambda function to deploy." +} + +variable "lambda_package" { + description = "The name of the lambda package. Used for a directory tree and zip file." + type = string + default = "anti-virus" +} + variable "lambda_package_key" { - description = "The object key for the lambda distribution. Defaults to lambda.zip since this is build by default upstream." + description = "The object key for the lambda distribution. If given, the value is used as the key in lieu of the value constructed using `lambda_package` and `lambda_version`." type = string - default = "lambda.zip" + default = null } variable "memory_size" {