@@ -39,14 +39,15 @@ def sanitize_bucket_name(name: str) -> str:
3939 return name # Enforce length limit
4040
4141
42- def zip_code (source_dir , zip_file ):
42+ def zip_code (source_dir , zip_file , ignore_dirs = None ):
4343 """
4444 Recursively zips the contents of source_dir into zip_file,
4545 preserving directory structure — suitable for AWS Lambda deployment.
4646
4747 Args:
4848 source_dir: str, the directory containing the Lambda function code.
4949 zip_file: str, the path where the zip file will be created.
50+ ignore_dirs: list, directories to ignore when zipping the code.
5051
5152 Returns:
5253 None
@@ -56,6 +57,16 @@ def zip_code(source_dir, zip_file):
5657 # Function should recursively zip all files and directories
5758 with zipfile .ZipFile (zip_file , 'w' , zipfile .ZIP_DEFLATED ) as zf :
5859 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+
5970 for file in files :
6071 click .echo (f"Adding { file } to zip" )
6172 file_path = os .path .join (root , file )
@@ -347,6 +358,7 @@ def command(
347358 region ,
348359 lambda_handler ,
349360 project_dir = None ,
361+ ignore_dirs = None
350362):
351363 """
352364 Command-line tool for deploying a trading bot to AWS Lambda.
@@ -358,6 +370,7 @@ def command(
358370 If None, it defaults to the current directory.
359371 lambda_handler: str, the name of the handler function in the code
360372 (default is "aws_function.lambda_handler").
373+ ignore_dirs: list, directories to ignore when zipping the code.
361374
362375 Returns:
363376 None
0 commit comments