Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.

Commit

Permalink
Add support for filename variable
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Jose Karam <[email protected]>
  • Loading branch information
NSCoder committed Apr 3, 2019
1 parent f4b34bb commit 7ba7757
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 8 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ locals {
application_name = "${var.application_name}"
application_environment = "${coalesce(var.application_environment, terraform.workspace)}"

source_path = "${var.source_path}"
file_name = "${local.file_name}"
handler = "${var.handler}"
runtime = "${var.runtime}"
timeout = "${var.timeout}"
Expand All @@ -18,11 +18,6 @@ locals {
}

# Lambda
data "archive_file" "lambda_archive" {
type = "zip"
source_file = "${local.source_path}"
output_path = "${local.source_path}.zip"
}

data "template_file" "lambda_template" {
template = "${local.handler}"
Expand Down Expand Up @@ -53,14 +48,13 @@ resource "aws_iam_role" "lambda_role" {
}

resource "aws_lambda_function" "lambda" {
function_name = "${local.application_name}_${data.template_file.lambda_template.rendered}_${local.application_environment}"
filename = "${data.archive_file.lambda_archive.output_path}"
source_code_hash = "${data.archive_file.lambda_archive.output_base64sha256}"
runtime = "${local.runtime}"
role = "${aws_iam_role.lambda_role.arn}"
handler = "${local.handler}"
timeout = "${local.timeout}"
memory_size = "${local.memory_size}"
function_name = "${local.application_name}_${data.template_file.lambda_template.rendered}_${local.application_environment}"
filename = "${local.file_name}"
runtime = "${local.runtime}"
role = "${aws_iam_role.lambda_role.arn}"
handler = "${local.handler}"
timeout = "${local.timeout}"
memory_size = "${local.memory_size}"

environment {
variables = "${local.environment_variables}"
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ variable "application_environment" {
default = ""
}

variable "source_path" {
variable "file_name" {
type = "string"
}

Expand Down

0 comments on commit 7ba7757

Please sign in to comment.