To create a Lambda function you first create a Lambda function deployment package, a .zip or .jar file consisting of your code and any dependencies. When creating the zip, include only the code and its dependencies, not the containing folder.

You can read more about building a deployment package in AWS documentation:

Build Script

A script for deployment package creation must be provided as a part of your delivery package. It will be used for function build and deployment automation, so it must be system environment independent:

  • do not reference files or folders located outside of your project folder
  • if you have dependencies that cannot be dowloaded/installed to the project folder, add them to source code repository
  • do not use non-standard commands, most likely they won’t be available on the build server. At the moment, on top of the docker ubuntu:16.04 the following utils are available on the build server: aws, python-pip, nodejs, zip, unzip, git, curl, boto3 (python lib)

Node.js

If you started your project from cn-example-lambda, your build script is already defined in the package.json scripts, otherwise you’ll need to add it there manually. The script will be used by the build server to build the deployment package (see Automatic Builds & Deployments for details).

// file: package.json
{
    "scripts": {
        "build": "npm prune --production && mkdir -p dist && zip -ro dist/$npm_package_name-$npm_package_version.zip src index.js package.json node_modules"
    }
}

Python

If you are using Python, put the deployment package build script to the ./scripts/build.sh