@@ -39,14 +39,15 @@ def sanitize_bucket_name(name: str) -> str:
39
39
return name # Enforce length limit
40
40
41
41
42
- def zip_code (source_dir , zip_file ):
42
+ def zip_code (source_dir , zip_file , ignore_dirs = None ):
43
43
"""
44
44
Recursively zips the contents of source_dir into zip_file,
45
45
preserving directory structure — suitable for AWS Lambda deployment.
46
46
47
47
Args:
48
48
source_dir: str, the directory containing the Lambda function code.
49
49
zip_file: str, the path where the zip file will be created.
50
+ ignore_dirs: list, directories to ignore when zipping the code.
50
51
51
52
Returns:
52
53
None
@@ -56,6 +57,16 @@ def zip_code(source_dir, zip_file):
56
57
# Function should recursively zip all files and directories
57
58
with zipfile .ZipFile (zip_file , 'w' , zipfile .ZIP_DEFLATED ) as zf :
58
59
for root , _ , files in os .walk (source_dir ):
60
+
61
+ # Skip ignored directories
62
+ if ignore_dirs is not None :
63
+ relative_root = os .path .relpath (root , source_dir )
64
+ if any (
65
+ relative_root .startswith (ignore ) for ignore in ignore_dirs
66
+ ):
67
+ click .echo (f"Ignoring directory: { relative_root } " )
68
+ continue
69
+
59
70
for file in files :
60
71
click .echo (f"Adding { file } to zip" )
61
72
file_path = os .path .join (root , file )
@@ -347,6 +358,7 @@ def command(
347
358
region ,
348
359
lambda_handler ,
349
360
project_dir = None ,
361
+ ignore_dirs = None
350
362
):
351
363
"""
352
364
Command-line tool for deploying a trading bot to AWS Lambda.
@@ -358,6 +370,7 @@ def command(
358
370
If None, it defaults to the current directory.
359
371
lambda_handler: str, the name of the handler function in the code
360
372
(default is "aws_function.lambda_handler").
373
+ ignore_dirs: list, directories to ignore when zipping the code.
361
374
362
375
Returns:
363
376
None
0 commit comments