Skip to content
This repository was archived by the owner on Mar 15, 2026. It is now read-only.
This repository was archived by the owner on Mar 15, 2026. It is now read-only.

Building from a non-working directory does not include any files into the bundle #120

Description

@Birne94

We are using one repository which includes multiple lambda configurations.

/dummy
	config-1.yaml
	config-2.yaml
	handler.py
	requirements.txt
/foo
	config.yaml
	handler.py
	requirements.txt

I created a little script to create packages for each of the functions:

#!/usr/bin/env python

import aws_lambda
import os

_cwd = os.getcwd()


def build(name, config='config.yaml'):
    aws_lambda.build(
        os.path.join(_cwd, name),
        requirements=os.path.join(_cwd, name, 'requirements.txt'),
        config_file=os.path.join(_cwd, name, config)
    )


build('dummy', 'config-1.yaml')
build('dummy', 'config-2.yaml')
build('foo')

The resulting packages only contain the installed requirements, but not any of the lambda handler itself.

This is caused by the isfile check in aws_lambda.build. It assumes that the current directory is the source directory since it does not join the directory and filename (as done 6 lines below).

possible fix:

--- /tmp/a	2018-08-07 11:28:35.000000000 +0200
+++ /tmp/b	2018-08-07 11:28:40.000000000 +0200
@@ -327,16 +327,17 @@
 
     files = []
     for filename in os.listdir(src):
-        if os.path.isfile(filename):
+        abs_filename = os.path.join(src, filename)
+        if os.path.isfile(abs_filename):
             if filename == '.DS_Store':
                 continue
             if filename == config_file:
                 continue
             print('Bundling: %r' % filename)
-            files.append(os.path.join(src, filename))
+            files.append(abs_filename)
         elif os.path.isdir(filename) and filename in source_directories:
             print('Bundling directory: %r' % filename)
-            files.append(os.path.join(src, filename))
+            files.append(abs_filename)
 
     # "cd" into `temp_path` directory.
     os.chdir(path_to_temp)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions