sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to obtain {sharp,next,image}_handler.zip

Pegasust opened this issue · comments

First, thank you for the provided example/*, it is very helpful on helping me integrating this project.
I have no idea how to acquire these zips, could you document more on how to obtain these zips?

commented

Hey! You can obtain them programmatically.

import { sharpLayerZipPath, imageHandlerZipPath, serverHandlerZipPath, nextLayerZipPath } from '@sladg/nextjs-lambda'

This will give you resolved path of these ZIPs on your disk (points to place inside node_modules).

I gave this a try sometime earlier and it seems AWS CDK did a silent error (say that there is no update to my empty stack).
Will give it a try sometime today and report back!

commented

Yeah! I faced the same problem with CDK not updating properly when being imported from the package.
I suggest either going for next-utils deploy command (documentation just got updated) or copying the CDK code to your app.

Thanks for the pointer to next-utils deploy! It's exactly what I missed.

Couple more nitpicky errors and we should be good to go:

 ❌ Deployment failed: Error: Stack Deployments Failed: Error: "--require-approval" is enabled and stack includes security-sensitive updates, but terminal (TTY) is not
 attached so we are unable to get a confirmation from the user
    at deployStacks (/home/ubuntu_admin/local_repos/c4c-monorepo-addon/node_modules/.pnpm/aws-cdk@2.41.0/node_modules/aws-cdk/lib/deploy.ts:61:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at CdkToolkit.deploy (/home/ubuntu_admin/local_repos/c4c-monorepo-addon/node_modules/.pnpm/aws-cdk@2.41.0/node_modules/aws-cdk/lib/cdk-toolkit.ts:312:7)
    at initCommandLine (/home/ubuntu_admin/local_repos/c4c-monorepo-addon/node_modules/.pnpm/aws-cdk@2.41.0/node_modules/aws-cdk/lib/cli.ts:349:12)

Stack Deployments Failed: Error: "--require-approval" is enabled and stack includes security-sensitive updates, but terminal (TTY) is not attached so we are unable to
 get a confirmation from the user

    at ChildProcess.exithandler (node:child_process:398:12)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

I think there are 2 ways we can fix this:

  1. Change this line to perform synchronous call with stdin and stdout pipe
  • currently, when running next-utils deploy, it blocks the output until it's done (might not be ideal)
  1. Tell the user to put their root cdk.json to have "requireApproval": "never" as documented here
  • I'm testing this approach. It's still blocking the output for a long while without any output (for around 5-7 minutes, which is scary for users)

I'm going to close this issue as approach 2 gives me a deployment to AWS.
Thank you for this project! You're the GOAT.