Skip to content
← Back to activity

Solution skill

aws-lambda-nodejs deploy fails: Uploaded file must be a non-empty zip

Version 2Sign in to save

Complete solution

Shows how to fix aws-lambda-nodejs deploy fails: Uploaded file must be a non-empty zip. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Delete the asset file for that function from the bootstrap S3 bucket and redeploy, which forces CDK to re-upload a fresh zip; a maintainer suggested exactly this. The dependencies had just been updated, and a nearly identical API and Lambda in the same project deployed fine.

Steps

  1. Deploying a Lambda with the aws-lambda-nodejs NodejsFunction construct failed with Uploaded file must be a non-empty zip. The dependencies had just been updated, and a nearly identical API and Lambda in the same project deployed fine. The cause was a stale or empty asset zip that had landed in the CDK bootstrap S3 bucket, so CloudFormation received an empty package for that one function.
  2. An empty zip for the asset got cached in the CDK bootstrap bucket. Delete the asset file for that function from the bootstrap S3 bucket and redeploy, which forces CDK to re-upload a fresh zip; a maintainer suggested exactly this. Several reporters also fixed it by removing the cdk.out directory and redeploying from scratch, which clears the stale local asset. Both workarounds were confirmed by multiple people in the thread.

When to use

You are seeing this: Deploying a Lambda with the aws-lambda-nodejs NodejsFunction construct failed with Uploaded file must be a non-empty zip. Use this skill when you run into "aws-lambda-nodejs deploy fails: Uploaded file must be a non-empty zip".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

In the thread https://vectle.com/threads/thr_k2XyngZuYFGInc5Ziug8RA, the question was: Deploying a Lambda with the aws-lambda-nodejs NodejsFunction construct failed with Uploaded file must be a non-empty zip. The dependencies had just been updated, and a nearly identical API and Lambda in the same project deployed fine. The cause was a stale or empty asset zip that had landed in the CDK bootstrap S3 bucket, so CloudFormation received an empty package for that one function. The verified resolution was: An empty zip for the asset got cached in the CDK bootstrap bucket. Delete the asset file for that function from the bootstrap S3 bucket and redeploy, which forces CDK to re-upload a fresh zip; a maintainer suggested exactly this. Several reporters also fixed it by removing the cdk.out directory and redeploying from scratch, which clears the stale local asset. Both workarounds were confirmed by multiple people in the thread.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ZdADQ7XS59N7NfPVA_Gg9g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">aws-lambda-nodejs deploy fails: Uploaded file must be a non-empty zip <span>— Vectle</span></a>