Skip to content

Cli: Uploaded file must be a non-empty zip #32869

Closed
@mostafasany

Description

@mostafasany

Describe the bug

Title: CDK Deploy Creates Empty Bootstrap File: "Uploaded file must be a non-empty zip" Error


Description:

When running cdk deploy, the deployment process fails with the following error:

Error: Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400)

This issue occurs due to the creation of an empty or invalid bootstrap file in the cdk.out directory.


Environment:

  • CDK Version: 2.175.1
  • Node.js Version: 18
  • OS: macOS
  • Additional Details:
    • Manually clearing the cdk.out folder does not resolve the issue.
    • File permissions and ownership of the cdk.out directory appear correct.
    • Running cdk bootstrap before deployment does not prevent the error.

Logs and Debug Information:
Relevant logs from cdk deploy --verbose:

Error: Uploaded file must be a non-empty zip
Screenshot 2025-01-13 at 01 04 39

Here is package.json of the CDK project written in TS

{
  "name": "cdk",
  "version": "0.1.0",
  "bin": {
    "cdk": "bin/cdk.js"
  },
  "scripts": {
    "build": "tsc",
    "watch": "tsc -w",
    "test": "jest",
    "cdk": "cdk",
    "cdk:deploy:default": "cdk deploy --profile default",
    "cdk:deploy:dev": "ENV=dev cdk deploy",
    "cdk:synth:dev": "ENV=dev cdk synth",
    "cdk:deploy:stage": "ENV=stage cdk deploy",
    "cdk:synth:stage": "ENV=stage cdk synth",
    "cdk:deploy:prod": "ENV=prod cdk deploy",
    "cdk:synth:prod": "ENV=prod cdk synth"

  },
  "devDependencies": {
    "@types/jest": "^29.5.14",
    "@types/node": "22.10.5",
    "aws-cdk": "^2.175.1",
    "jest": "^29.7.0",
    "ts-jest": "^29.2.5",
    "ts-node": "^10.9.2",
    "typescript": "~5.7.3"
  },
  "dependencies": {
    "aws-cdk-lib": "^2.175.1",
    "cdk-ecr-deployment": "^3.1.4",
    "constructs": "^10.4.2",
    "source-map-support": "^0.5.21"
  }
}

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Expected Behavior:

The deployment should proceed without errors, and all generated files, including the bootstrap file, should be valid and non-empty.


Current Behavior

Observed Behavior:

The cdk.out directory contains an empty or invalid file for the relevant custom resource, leading to the error:

Error: Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400)

Reproduction Steps

  1. Create a CDK stack containing resources like AWS::Lambda::Function or AWS::S3::Bucket.
  2. Run:
    npm install
    cdk synth
    cdk deploy
  3. Observe the error during deployment.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.175.1

Framework Version

No response

Node.js Version

18

OS

macOS

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.effort/mediumMedium work item – several days of effortp2package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions