serverless icon indicating copy to clipboard operation
serverless copied to clipboard

the-big-fan npm run deploy result in error

Open andsus opened this issue 2 years ago • 1 comments

Steps: On cloud9 git clone https://github.com/cdk-patterns/serverless.git cd the-big-hit npm run build npm run deploy

9:08:16 PM | CREATE_FAILED        | AWS::Lambda::Function           | SQSCreatedStatusSu...bdaHandler0467DB95
Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400, Request ID: b2f597b6-3556-4df6-8d90-3541ed3ed7c0)" (RequestToken: b2579
b25-26d2-662e-ff4b-28fb634df493, HandlerErrorCode: InvalidRequest)

        new Function (/home/ec2-user/environment/serverless/the-big-fan/typescript/node_modules/@aws-cdk/aws-lambda/lib/function.ts:608:35)
        \_ new TheBigFanStack (/home/ec2-user/environment/serverless/the-big-fan/typescript/lib/the-big-fan-stack.ts:65:45)
        \_ Object.<anonymous> (/home/ec2-user/environment/serverless/the-big-fan/typescript/bin/the-big-fan.ts:7:1)
        \_ Module._compile (node:internal/modules/cjs/loader:1126:14)
        \_ Module.m._compile (/home/ec2-user/environment/serverless/the-big-fan/typescript/node_modules/ts-node/src/index.ts:1056:23)
        \_ Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
        \_ Object.require.extensions.<computed> [as .ts] (/home/ec2-user/environment/serverless/the-big-fan/typescript/node_modules/ts-node/src/index.ts:1059:12)
        \_ Module.load (node:internal/modules/cjs/loader:1004:32)
        \_ Function.Module._load (node:internal/modules/cjs/loader:839:12)

Same issue with the-scalable-webhook

andsus avatar Sep 18 '22 21:09 andsus

I ran into the same issue but with the-eventbridge-etl. The issue seemed to be caused by the fact that I had previously deployed a template using v2 of the CDK, and these templates are using v1.

To resolve the issue, I followed these steps:

  1. Created a new CDK project, using cdk init app --language=typescript in a new directory
  2. Copied over the code and replaced the "aws-cdk" entries with "aws-cdk-lib" entries (basically switching from v1 to v2 of the CDK)
  3. (Optional) added platform: Platform.LINUX_AMD64 in ContainerImage.fromAsset as I am running cdk deploy from a Mac with M1 chip and the Fargate task running the docker container was throwing exec format error. I also updated the Makefile for the container at the stage where docker build is called, to use --platform=linux/amd64.

After making these changes, I was able to deploy and run the-eventbridge-etl pattern successfully. Hopefully these steps will help.

sumitlni avatar Oct 02 '22 04:10 sumitlni