Skip to content
Open
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
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,21 @@ module "source_zip_file" {
# (if build mode is CODEBUILD, LAMBDA, S3) #
############################################

resource "aws_s3_bucket_object" "source_zip_file" {
resource "aws_s3_object" "source_zip_file" {
count = var.enabled && contains(["CODEBUILD", "LAMBDA", "S3"], var.build_mode) ? 1 : 0

bucket = var.s3_bucket
key = contains(["CODEBUILD", "LAMBDA"], var.build_mode) ? "${var.function_name}/${module.source_zip_file.output_sha}/source.zip" : var.s3_key
source = module.source_zip_file.output_path
source_hash = module.source_zip_file.output_base64sha256

lifecycle {
create_before_destroy = true
}
}

locals {
source_zip_file_s3_key = var.enabled && contains(["CODEBUILD", "LAMBDA", "S3"], var.build_mode) ? aws_s3_bucket_object.source_zip_file[0].key : null
source_zip_file_s3_key = var.enabled && contains(["CODEBUILD", "LAMBDA", "S3"], var.build_mode) ? aws_s3_object.source_zip_file[0].key : null
}

###############################################
Expand Down