diff --git a/README.md b/README.md index 9f2a149..903ce44 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,7 @@ module "s3_anti_virus" { name_update = "s3-anti-virus-updates" lambda_s3_bucket = "lambda-builds-us-west-2" - lambda_version = "2.0.0" - lambda_package = "anti-virus" + lambda_package_key = "lambda.zip" av_update_minutes = "180" av_scan_buckets = ["bucket-name"] diff --git a/anti-virus-scan.tf b/anti-virus-scan.tf index ce6f10f..8b019a9 100644 --- a/anti-virus-scan.tf +++ b/anti-virus-scan.tf @@ -167,7 +167,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}/${var.lambda_version}/${var.lambda_package}.zip" + 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 07ee2bd..d8118a4 100644 --- a/anti-virus-update.tf +++ b/anti-virus-update.tf @@ -124,7 +124,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}/${var.lambda_version}/${var.lambda_package}.zip" + 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 3ef79a4..9a9b651 100644 --- a/variables.tf +++ b/variables.tf @@ -23,7 +23,6 @@ variable "lambda_s3_bucket" { variable "lambda_version" { description = "The version the Lambda function to deploy." - type = string } variable "lambda_package" { @@ -32,6 +31,12 @@ variable "lambda_package" { default = "anti-virus" } +variable "lambda_package_key" { + 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 = null +} + variable "memory_size" { description = "Lambda memory allocation, in MB" type = string