Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ data "archive_file" "zip_file_for_lambda" {
* Doing this makes the plans more resiliant, where it won't always
* appear that the function needs to be updated
*/
resource "aws_s3_bucket_object" "artifact" {
resource "aws_s3_object" "artifact" {
count = var.s3_artifact_bucket == null ? 0 : 1
bucket = var.s3_artifact_bucket
key = "${var.name}.zip"
source = data.archive_file.zip_file_for_lambda.output_path
Expand All @@ -57,21 +58,17 @@ resource "aws_lambda_function" "lambda" {

# Find the file from S3
s3_bucket = var.s3_artifact_bucket
s3_key = aws_s3_bucket_object.artifact.id
s3_object_version = aws_s3_bucket_object.artifact.version_id
s3_key = var.s3_artifact_bucket == null ? null : aws_s3_object.artifact.0.id
s3_object_version = var.s3_artifact_bucket == null ? null : aws_s3_object.artifact.0.version_id

filename = var.s3_artifact_bucket == null ? data.archive_file.zip_file_for_lambda.output_path : null
source_code_hash = filebase64sha256(data.archive_file.zip_file_for_lambda.output_path)

publish = true
handler = var.handler
runtime = var.runtime
role = aws_iam_role.lambda_at_edge.arn
tags = var.tags

lifecycle {
ignore_changes = [
last_modified,
]
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ variable description {

variable s3_artifact_bucket {
description = "Name of the S3 bucket to upload versioned artifacts to"
default = null
}

variable tags {
Expand Down