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

Building Assets Failed: Error: StandaloneNextjsStack-Temporary: SSM parameter /cdk-bootstrap/hnb659fds/version not found.

pavlo-mais opened this issue · comments

Steps to reproduce
next build
npx --package @sladg/nextjs-lambda next-utils pack
npx --package @sladg/nextjs-lambda next-utils deploy
I get

[paul@rb demo-app]$ npx --package @sladg/nextjs-lambda next-utils deploy
Our config is:  {
  stackName: 'StandaloneNextjsStack-Temporary',
  appPath: '/home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/@sladg/nextjs-lambda/dist/cdk-app.js'
}
stdout: 
✨  Synthesis time: 1.63s


stdout: StandaloneNextjsStack-Temporary: building assets...


stdout: current credentials could not be used to assume 'arn:aws:iam::661723878467:role/cdk-hnb659fds-deploy-role-661723878467-us-east-1', but are for the right account. Proceeding anyway.

stderr: 
 ❌ Building assets failed: Error: Building Assets Failed: Error: StandaloneNextjsStack-Temporary: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
    at buildAllStackAssets (/home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/build.ts:21:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at CdkToolkit.deploy (/home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/cdk-toolkit.ts:175:7)
    at initCommandLine (/home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/cli.ts:357:12)

stdout: 

stderr: Building Assets Failed: Error: StandaloneNextjsStack-Temporary: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)

Process failed with error: Error: Command failed: STACK_NAME=StandaloneNextjsStack-Temporary /home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/bin/cdk deploy --app "node /home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/@sladg/nextjs-lambda/dist/cdk-app.js" --require-approval never --ci

 ❌ Building assets failed: Error: Building Assets Failed: Error: StandaloneNextjsStack-Temporary: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
    at buildAllStackAssets (/home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/build.ts:21:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at CdkToolkit.deploy (/home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/cdk-toolkit.ts:175:7)
    at initCommandLine (/home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/lib/cli.ts:357:12)
Building Assets Failed: Error: StandaloneNextjsStack-Temporary: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)

    at ChildProcess.exithandler (node:child_process:400:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1093:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'STACK_NAME=StandaloneNextjsStack-Temporary /home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/aws-cdk/bin/cdk deploy --app "node /home/paul/.npm/_npx/3b877e98bdaa260f/node_modules/@sladg/nextjs-lambda/dist/cdk-app.js" --require-approval never --ci'
}

Is something missing in README.md?
Do I really need to run cdk bootstrap manually?
Thanks.

commented

Hey! It looks like you did not bootstrap your environment.
You need to run it manually outside of this script, the reason being speed - if it would be part of this package, it would most likely need to run every time, resulting in slower deployment times and unnecessary steps in case you have already bootstrapped once.

Try running npx cdk aws://661723878467/us-east-1.

I will try to look into it, if there is possibility to check and provide better error message at least.

commented

Oki, looked into it, discussed the option and here we go.
deploy command has --bootstrap option, if you pass this flag, it will boostrap your environment before deploying 💯
See: 4fe52f4

Available in version 3.15.0

Thank You.