Skip to main content

How Do I Upload AWS Lambda Code?

by
Last updated on 3 min read

Quick Fix

Zip your code, upload it through the Lambda console, then hit Save. That’s all it takes.

What's Happening

AWS Lambda runs your function code from a ZIP file.

Before Lambda can execute anything, it needs your code packaged up in a ZIP. The console quietly handles the heavy lifting—uploading that ZIP to an S3 bucket, unpacking it, and keeping it ready to run when triggered. No ZIP? No code. And without code, your function can’t do a thing.

Step-by-Step Solution

Here’s exactly how to upload your Lambda code.
  1. Package your code
    • On Linux or macOS, run: zip -r function.zip .
    • In Windows PowerShell, use: Compress-Archive -Path * -DestinationPath function.zip
  2. Head to the Lambda console
  3. Select your function
    • Scroll through the list and click the name of the function you want to update.
  4. Upload the ZIP file
    • In the “Code source” section, click Upload from.zip file.
    • Find and select your function.zip file.
  5. Save your changes
    • Click Save in the top-right corner.
    • Wait for the green “Saved” banner to appear—it confirms everything went through.

If This Didn't Work

Try these fixes in order if your upload fails.

Start with the simplest solution and move down the list:

  • Console upload timeout
    • Big ZIP files (over 50 MB) often time out in the console. They need to go through S3 first.
    • Upload your ZIP to S3, then paste the S3 object URL into Lambda’s “Code” → “Code source” → “Amazon S3 location” field. Hit Save and you’re done.
  • Deploy via the AWS CLI
    • Install AWS CLI version 2, then run:
      aws lambda update-function-code \
        --function-name MyFunction \
        --zip-file fileb://function.zip
  • Missing layers
    • If your code depends on extra libraries—like pandas—you’ll need a layer.
      1. Go to the Lambda console, open Layers, and click Create layer.
      2. Upload the layer ZIP (make sure it matches your Lambda runtime).
      3. Back in your function, click Layers → Add a layer and select the one you just created.

Prevention Tips

Keep upload headaches from happening again.
Tip Action
Version control Push your code to GitHub or GitLab and tag releases. Use git archive to auto-build ZIPs whenever you tag—no more manual packaging.
CI pipeline Set up a GitHub Action that runs sam build after every push, then deploys with sam deploy. No more forgetting to update your function.
Environment parity Test locally first using AWS SAM CLI. It spins up a local Lambda environment so you can catch ZIP packaging issues before they reach AWS.
Clean up old versions Lambda never deletes old code. Head to the console or run a CLI command to remove unused versions—otherwise, you’ll hit the 75 GB storage limit faster than you’d expect.
David Okonkwo
Author

David Okonkwo holds a PhD in Computer Science and has been reviewing tech products and research tools for over 8 years. He's the person his entire department calls when their software breaks, and he's surprisingly okay with that.

What Is Duping In Diablo?Should All The First Letters In A Title Be Capitalized?