Skip to content

Commit

Permalink
Merge pull request #24 from theherk/less-opinionated-key
Browse files Browse the repository at this point in the history
Let the user pick the object key.
  • Loading branch information
Michael Kania authored Oct 4, 2021
2 parents 622d4cf + 20fee82 commit 81cf772
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion anti-virus-scan.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion anti-virus-update.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"
}
7 changes: 6 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ variable "lambda_s3_bucket" {

variable "lambda_version" {
description = "The version the Lambda function to deploy."
type = string
}

variable "lambda_package" {
Expand All @@ -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
Expand Down

0 comments on commit 81cf772

Please sign in to comment.