Skip to content

Commit

Permalink
Add back variables to maintain compatibility.
Browse files Browse the repository at this point in the history
Override, default prefix construction when lambda_key_prefix is given.
  • Loading branch information
theherk committed Aug 30, 2021
1 parent 6d1250f commit 20fee82
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion anti-virus-scan.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion anti-virus-update.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
14 changes: 12 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 20fee82

Please sign in to comment.