If your Lambda function isn’t picking up your code changes, zip your project folder and upload the file through the Lambda console, AWS CLI, or Amazon S3.
What's Happening
AWS Lambda needs your code packaged as a ZIP file before it can run
AWS Lambda won’t even consider your code until it’s tucked inside a proper ZIP archive. When you upload that ZIP, Lambda automatically unpacks it into the /var/task directory inside the execution environment. Miss a file, forget a dependency, or structure the folders wrong, and Lambda either ignores your upload or throws a “no code” error. The console hides this from you, but your ZIP actually lives in an internal Amazon S3 bucket tied to your account.
Step-by-Step Solution
Create a ZIP of your project, then upload it through the console, CLI, or S3
These instructions work whether you’re using the AWS Management Console, AWS CLI v2 (as of 2026), or most runtimes released since 2024.
- Create the ZIP file
- On macOS or Linux (Terminal)
cd /path/to/your/project
zip -r function.zip . -x "*.git*" "*.DS_Store" "*.vscode/*" "node_modules/.bin/*"
- On Windows (PowerShell)
cd C:\src\my-lambda
Compress-Archive -Path * -DestinationPath function.zip -CompressionLevel Optimal
- Double-check the ZIP size—anything over 50 MB will need S3 upload.
- Open the Lambda console
- Head to AWS Lambda console and sign in.
- In the top-right corner, confirm the region matches where you want to deploy (for example, US East (N. Virginia) us-east-1).
- Find and open your function
- In the list, click the function name (for example,
report-generator-prod).
- Can’t find it? Use the search bar at the top and type part of the function name.
- Upload the ZIP
- In the function page, click the Code tab.
- Under Code source, choose Upload from → .zip file.
- Browse to
function.zip, select it, and click Open.
- Click Save in the top-right corner; wait for the green banner “Code updated successfully.”
If This Didn't Work
Try uploading via S3 for large ZIPs, or use the CLI to push your code
Start with the simplest fixes and move down the list only if you’re still stuck:
- Upload via S3 when the ZIP is large
- Head to Amazon S3 console.
- Create a bucket or use an existing one (for example,
my-lambda-builds-2026).
- Upload
function.zip to the bucket and note the object URL (for example, s3://my-lambda-builds-2026/function.zip).
- Back in Lambda, choose Code source → Amazon S3 location, paste the URL, and click Save.
- Deploy with AWS CLI v2
- Install AWS CLI v2 (Windows, macOS, Linux) from AWS CLI Install Guide.
- Run:
aws lambda update-function-code \
--function-name report-generator-prod \
--zip-file fileb://function.zip \
--region us-east-1
- Using container images instead? Try:
aws lambda update-function-code \
--function-name my-container-function \
--image-uri 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-image:latest
- Fix missing dependencies or wrong handler path
- Open the ZIP and confirm
lambda_function.py (Python) or index.js (Node.js) is in the root unless your handler path expects a subfolder (for example, src/lambda_function.handler requires the file at src/lambda_function.py).
- Need libraries like NumPy? Package them in a Lambda layer: create a folder
python/lib/python3.12/site-packages, install dependencies there, ZIP it, then upload as a layer in the Lambda console under Layers → Add a layer.
Prevention Tips
Pin runtime versions, automate builds, test locally, and clean old versions to keep uploads smooth
These habits prevent “no code” errors and make future uploads painless.
| Tip |
Action |
| Pin runtime versions |
In runtime.txt (Python) or package.json (Node.js), pin versions like python 3.12 and aws-lambda-powertools 2.15.0 to avoid surprises. |
| Automate ZIP builds |
Use GitHub Actions to build and upload on every push:
- name: Build ZIP
run: zip -r function.zip . -x "*.git*"
Honestly, this is the best approach for consistency. |
| Test locally first |
Install AWS SAM CLI and run:
sam local invoke MyFunction -e events/test.json
This catches missing files before you upload to AWS. |
| Clean old versions |
List versions:
aws lambda list-versions-by-function --function-name MyFunction
Delete old ones:
aws lambda delete-function --function-name MyFunction:1
This keeps your account under the 75 GB storage limit. |
Follow these steps and your Lambda function will always have the right code and dependencies when it runs.
How Do I Upload AWS Lambda Code?
You upload AWS Lambda code by zipping it up and sending it through the Lambda console, AWS S3, or the CLI
What Actually Happens When You Upload Code
Lambda won’t run your code until it’s properly packaged in a ZIP and uploaded to AWS
When you send that ZIP file to Lambda, AWS unpacks it automatically into the /var/task directory where your function executes. The console handles most of this behind the scenes—it stashes your ZIP in an S3 bucket first, then makes it available to your function. Skip this step and Lambda will throw a “no code” error. Always double-check your ZIP contains every file and dependency, either in the root or in a subfolder that matches your runtime’s expectations.
Here’s How to Actually Do It
Start by zipping your code, then push it to Lambda through the console or CLI
- Zip everything up
- On Linux or macOS:
zip -r function.zip . (run this from your project’s root folder)
- In Windows PowerShell:
Compress-Archive -Path * -DestinationPath function.zip
- Trim the fat with
zip -r function.zip . -x "*.git*" "*.DS_Store" so your ZIP stays under 50 MB
- Head to the Lambda console
- Pick your function
- Scroll through the list and click the function you want to update (for example, “MyAnalyticsFunction”)
- Upload and confirm
- In the “Code source” tab, choose Upload from → .zip file
- Select your freshly made
function.zip and hit Open
- Click Save in the top-right corner; wait for the green “Code updated successfully” banner
Upload Still Failing? Try These Fixes
Fix upload failures by checking file size, S3 setup, CLI commands, or missing layers
Work through these fixes in order—start simple and escalate only if needed:
- Console chokes on big ZIPs
- ZIP files over 50 MB usually fail when uploaded directly in the console. Upload to S3 first, then point Lambda to that S3 location under “Code source” → “Amazon S3 location”
- Deploy with the AWS CLI (v2)
- Install AWS CLI v2 from the official docs
- Run:
aws lambda update-function-code --function-name MyFunction --zip-file fileb://function.zip
- Use
--image-uri if you’re using container images
- Forgot to bundle dependencies
- If your code needs libraries like NumPy or pandas, create a Lambda layer
- Package those dependencies in a folder such as
python/lib/python3.12/site-packages, ZIP it, then upload it as a layer that matches your function’s runtime
- Handler file ends up in the wrong place
- Lambda looks for your handler file (for example,
lambda_function.py) either in the ZIP’s root or in a folder that matches the handler path (for example, src/lambda_function.py with handler src.lambda_function.handler)
Keep Upload Problems From Happening Again
Use version control, automated pipelines, and local testing to avoid upload headaches
These practices keep your uploads consistent and error-free.
| Tip |
What to do |
| Version control |
Stash your code in GitHub or GitLab and tag releases like v1.0.0. Automate ZIP creation with git archive v1.0.0 -o function.zip so every build is identical |
| CI pipeline |
Set up a GitHub Action that runs AWS SAM CLI to build and deploy on every push: sam build → sam deploy --guided |
| Local testing |
Spin up AWS SAM CLI to test locally before you deploy: sam local invoke MyFunction -e event.json |
| Clean up old versions |
List old versions with aws lambda list-versions-by-function --function-name MyFunction and delete anything older than you need with aws lambda delete-function --function-name MyFunction:1 to stay under the 75 GB account limit |
Edited and fact-checked by the TechFactsHub editorial team.