Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to do deployment through Windows with WSL #93

Closed
hugumoraes opened this issue Mar 16, 2023 · 2 comments · Fixed by #103
Closed

Unable to do deployment through Windows with WSL #93

hugumoraes opened this issue Mar 16, 2023 · 2 comments · Fixed by #103

Comments

@hugumoraes
Copy link

When trying to deploy a NextjsDistribution to AWS through a Windows environment, some commands doesn't from WSL doesn't work properly because of paths or syntax.
That happens when bundling the ImageOptimizationLambda and when building NextjsBuild.

Expected Behavior

Run cdk deploy, bundle and deploy the NextjsDistribution.

├ Running "yarn build" in <path>
$ next build
info  - Linting and checking validity of types
info  - Compiled successfully
info  - Collecting page data
info  - Generating static pages (3/3)
info  - Finalizing page optimization

Route (pages)                              Size     First Load JS
┌ ○ /                                      443 B          73.7 kB
├   /_app                                  0 B            73.3 kB
└ ○ /404                                   182 B          73.4 kB
+ First Load JS shared by all              73.3 kB
  ├ chunks/framework-2c79e2a64abdb08b.js   45.2 kB
  ├ chunks/main-0ecb9ccfcb6c9b24.js        27 kB
  ├ chunks/pages/_app-2855696d374eec2d.js  287 B
  └ chunks/webpack-8fa1640cc84ba8fe.js     750 B

○  (Static)  automatically rendered as static HTML (uses no initial props)

info  - Creating an optimized production build ..+ cd /mnt/<path>/standalone
+ zip -ryq1 /mnt/c/Users/<user>/AppData/Local/Temp/standalone-IinlJm/standalone.zip .
Bundling asset DEV-Web-Admin-MAIN/<Stack_Name>-Web-Admin-ImageOpsLambda-DEV/Code/Stage...
D:\<path>\required-server-files.json
        1 file(s) copied.
warning package.json: No license field
$ D:\<path>\node_modules\.bin\esbuild --bundle D:\<path>\node_modules\cdk-nextjs-standalone\assets\lambda\ImageOptimization\index.ts --target=node16 --platform=node --outfile=D:\<path>\cdk.out\bundling-temp-11162cfe73d40f0248812214cb3d7a6342de11bdaadacd770b227a07922345df\index.js --minify

  cdk.out\bundling-temp-11162cfe73d40f0248812214cb3d7a6342de11bdaadacd770b227a07922345df\index.js  1.3mb

[Warning at /DEV-Web-Admin-MAIN/<Stack_Name>-Web-Admin-Distribution-DEV/DefaultOriginRequestEdgeFn/Fn] AWS Lambda has changed their authorization strategy, which may cause client invocations using the 'Qualifier' parameter of the lambda function to fail with Access Denied errors.
If you are using a lambda Version or Alias, make sure to call 'grantInvoke' or 'addPermission' on the Version or Alias, not the underlying Function
See: https://github.com/aws/aws-cdk/issues/19273

✨  Synthesis time: 21.61s

DEV-Certificate-MAIN (DEV-Certificate-ADMINWEB): building assets...

Current Behavior

Whenever bundling with Windows and WSL, deployment will throw an error with the .zip compression on NextjsBuild.ts at line 259 because paths syntax is different.
Then, fixing it, ImageOptimizationLambda.ts will fail at line 80 because cp is not recognize as a valid command (it is copy at windows environment)

Steps to Reproduce

  1. Create a stack with all necessary constructs: Bucket, NextjsBuild, NextjsLayer, NextJsLambda, ImageOptimizationLambda and NextjsDistribution.

Context (Environment)

I am trying to do test deployments on my machine before creating a CI/CD to handle the deployment on AWS side, I was able to do the testing by manually changing those lines in node_modules, but would be cool to support it natively from the library.

@revmischa
Copy link
Member

Would you be open to fixing them and submitting a PR?
Or it may be better to swap out NextBuild for https://open-next.js.org/

@hugumoraes
Copy link
Author

Sure, I'll have it in a couple days and submit for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants