Skip to content

Commit 74a5013

Browse files
committed
wip
1 parent a3a435f commit 74a5013

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

terraform/package_lambda.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ set -e
33

44
echo "🚀 Packaging Lambda1..."
55

6+
# parameters passed in as project_name project_folder abs_build_folder zip_file_name
7+
8+
69
PROJECT="${1:-.}"
7-
PROJECT_DIR=$(realpath "$PROJECT") # Default to current dir if not provided
8-
BUILD_DIR="${2:-build}" # Default build directory if not provided
9-
ZIP_FILE="${3:-lambda_package.zip}" # Default zip file name if not provided
10+
PROJECT_DIR="${2:-$(realpath \"$PROJECT\")}" # Default to current dir if not provided
11+
BUILD_DIR="${3:-build}" # Default build directory if not provided
12+
ZIP_FILE="${4:-$PROJECT.zip}" # Default zip file name if not provided
1013
echo "Project directory: $PROJECT_DIR"
1114
echo "Build directory: $BUILD_DIR"
15+
echo "Zip file: $ZIP_FILE"
1216

1317
# show current directory
1418
echo "📂 Current directory: $(pwd)"
@@ -55,9 +59,8 @@ cd ..
5559
echo "📂 Current directory: $(pwd)"
5660

5761
#list contents of the build directory
58-
echo "📂 Contents of build directory: $(ls -1 $BUILD_DIR)"
62+
echo "📂 Contents of build directory: $(ls -1 $BUILD_DIR/$ZIP_FILE)"
5963

60-
echo "📂 Contents of project directory: $(ls -1 $PROJECT_DIR)"
61-
echo "📂 Contents of parent directory: $(ls -1 $PROJECT_DIR/..)"
64+
echo "📂 Contents of parent directory: $(ls -1 $PROJECT_DIR/$ZIP_FILE)"
6265

6366
echo "✅ Lambda package created: $ZIP_FILE"

terraform/redis_sync_lambda.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Define the directory containing source code and calculate its SHA-256 hash for triggering redeployments
22
locals {
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

3538
resource "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

4753
data "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

Comments
 (0)