11# Define the directory containing source code and calculate its SHA-256 hash for triggering redeployments
22locals {
3- redis_sync_dir = abspath (" ${ path . root } /../redis_sync" )
3+ redis_project_name = " redis_sync"
4+ redis_sync_dir = abspath (" ${ path . root } /../${ local . redis_project_name } " )
5+ build_dir = " ${ local . redis_sync_dir } /build"
6+ zip_file_name = " redis_sync_lambda.zip"
47 redis_sync_files = fileset (local. redis_sync_dir , " **" )
58 redis_sync_dir_sha = sha1 (join (" " , [for f in local . redis_sync_files : filesha1 (" ${ local . redis_sync_dir } /${ f } " )]))
69}
@@ -34,7 +37,10 @@ resource "null_resource" "chmod_package_lambda" {
3437
3538resource "null_resource" "package_lambda" {
3639 provisioner "local-exec" {
37- command = " chmod +x ${ path . module } /package_lambda.sh && ${ path . module } /package_lambda.sh ${ local . redis_sync_dir } "
40+ command = <<- EOT
41+ chmod +x ${ path . module } /package_lambda.sh && \
42+ ${ path . module } /package_lambda.sh ${ local . redis_project_name } ${ local . redis_sync_dir } ${ local . build_dir } ${ local . zip_file_name }
43+ EOT
3844 }
3945 depends_on = [null_resource. chmod_package_lambda ]
4046 triggers = {
@@ -46,8 +52,8 @@ command = "chmod +x ${path.module}/package_lambda.sh && ${path.module}/package_l
4652
4753data "archive_file" "redis_sync_lambda_zip" {
4854 type = " zip"
49- source_dir = " ${ path . module } /build "
50- output_path = " ${ path . module } /build/redis_sync_lambda.zip "
55+ source_dir = " ${ local . build_dir } "
56+ output_path = " ${ local . build_dir } / ${ local . zip_file_name } "
5157
5258 depends_on = [null_resource. package_lambda ]
5359}
0 commit comments