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.
MIT License
173 stars 19 forks source link

Deployment fails at ImageOptimization Handler #58

Closed khuezy closed 1 year ago

khuezy commented 1 year ago

Hi, when I run npx --package ... deploy

Failed resources:
StandaloneNextjsStack-Temporary | 2:28:51 PM | UPDATE_FAILED        | AWS::Lambda::Function                           | ImageOptimizationNextJs (ImageOptimizationNextJsB167CF66) Resource handler returned message: "Lambda function StandaloneNextjsStack-Tem-ImageOptimizationNextJsB-MAFjARSAA8QV could not be found" (RequestToken: bd6daa8c-9bf9-6640-0e13-9dc06fb19e9c, HandlerErrorCode: NotFound)

stderr: 
 ❌  StandaloneNextjsStack-Temporary failed: Error: The stack named StandaloneNextjsStack-Temporary failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Lambda function StandaloneNextjsStack-Tem-ImageOptimizationNextJsB-MAFjARSAA8QV could not be found" (RequestToken: bd6daa8c-9bf9-6640-0e13-9dc06fb19e9c, HandlerErrorCode: NotFound)
    at FullCloudFormationDeployment.monitorDeployment (/Users/user/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/api/deploy-stack.ts:505:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at deployStack2 (/Users/user/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/cdk-toolkit.ts:264:24)
    at /Users/user/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/deploy.ts:39:11
    at run (/Users/user/.npm/_npx/3b877e98bdaa260f/node_modules/p-queue/dist/index.js:163:29)

stderr: 
 ❌ Deployment failed: Error: Stack Deployments Failed: Error: The stack named StandaloneNextjsStack-Temporary failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Lambda function StandaloneNextjsStack-Tem-ImageOptimizationNextJsB-MAFjARSAA8QV could not be found" (RequestToken: bd6daa8c-9bf9-6640-0e13-9dc06fb19e9c, HandlerErrorCode: NotFound)
    at deployStacks (/Users/user/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/deploy.ts:61:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at CdkToolkit.deploy (/Users/user/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/cdk-toolkit.ts:338:7)
    at initCommandLine (/Users/user/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/cli.ts:364:12)
khuezy commented 1 year ago

passing ... deploy --stackName newStackName fixes it.

sladg commented 1 year ago

From the error message, it seems like deployment happened and then ImageOptimization lambda was manually deleted causing drift in the stack.

Changing --stackName parameter ultimately results in all resources being re-deployed, thus fixing the problem.

Is my assumption correct?

khuezy commented 1 year ago

Ooops sorry for late reply, yup that's what happened. Thanks!