diff --git a/main.tf b/main.tf index 2dc21bf..c1ad102 100644 --- a/main.tf +++ b/main.tf @@ -50,12 +50,13 @@ 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 @@ -63,7 +64,7 @@ resource "aws_s3_bucket_object" "source_zip_file" { } 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 } ###############################################