File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 11locals {
22 source_dir = var. source_dir
3+ use_prebuilt_zip = var. filename != null
34}
45
56# Template files for user reference
@@ -38,9 +39,9 @@ resource "local_file" "makefile_template" {
3839# ]
3940# }
4041
41- # Create zip package from source directory (only for Zip package type)
42+ # Create zip package from source directory (only for Zip package type and when not using prebuilt )
4243data "archive_file" "lambda_zip" {
43- count = var. package_type == " Zip" ? 1 : 0
44+ count = var. package_type == " Zip" && ! local . use_prebuilt_zip ? 1 : 0
4445
4546 type = " zip"
4647 source_dir = local. source_dir
@@ -125,8 +126,8 @@ resource "aws_lambda_function" "this" {
125126 package_type = var. package_type
126127
127128 # Zip package configuration
128- filename = var. package_type == " Zip" ? data. archive_file . lambda_zip [0 ]. output_path : null
129- source_code_hash = var. package_type == " Zip" ? data. archive_file . lambda_zip [0 ]. output_base64sha256 : null
129+ filename = var. package_type == " Zip" ? (local . use_prebuilt_zip ? var . filename : data. archive_file . lambda_zip [0 ]. output_path ) : null
130+ source_code_hash = var. package_type == " Zip" ? (local . use_prebuilt_zip ? filebase64sha256 (var . filename ) : data. archive_file . lambda_zip [0 ]. output_base64sha256 ) : null
130131 handler = var. package_type == " Zip" ? var. handler : null
131132 runtime = var. package_type == " Zip" ? var. runtime : null
132133
Original file line number Diff line number Diff line change 11variable "source_dir" {
22 type = string
33 description = " Path to the source directory containing Lambda function code"
4+ default = null
45}
56
67variable "handler" {
@@ -105,3 +106,9 @@ variable "image_config" {
105106 description = " Container image configuration"
106107 default = null
107108}
109+
110+ variable "filename" {
111+ type = string
112+ description = " Path to pre-built zip file (alternative to source_dir)"
113+ default = null
114+ }
You can’t perform that action at this time.
0 commit comments