---
title: "Comment by DK on \"On-the-fly image resizing with AWS Lambda, S3 & CloudFront\" | Hashnode"
description: "Hi Stefan, I followed your instruction but when I visited the URL to resize image, it just showed AccessDenied. The URL for the original image still works."
url: "https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42/comment/62148a5695c64c6eda455e36"
---

[Discussion](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42)

Comment [On-the-fly image resizing with AWS Lambda, S3 & CloudFront](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42)

[DK](https://hashnode.com/@kakallatt)

[Feb 22, 2022](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42/comment/62148a5695c64c6eda455e36)

Hi Stefan,

I followed your instruction but when I visited the URL to resize image, it just showed AccessDenied. The URL for the original image still works.

[DK](https://hashnode.com/@kakallatt)

[Feb 22, 2022](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42/comment/62148a5695c64c6eda455e36#reply-62148da8b8d3826eb56656e8)

Oh seems I can visit via the CloudFront URL, but I got this error from the code in .zip file:

`index.handler is undefined or not exported`

[Stefan Olaru](https://hashnode.com/@stefanolaru)

[Feb 22, 2022](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42/comment/62148a5695c64c6eda455e36#reply-6214c92eb8d3826eb5665f8f)

[DK](https://hashnode.com/@kakallatt) I think the github zip wraps the content in a folder "imageresizer-main", please make sure you upload to lambda the code from the folder, so the index.js goes in the root

[DK](https://hashnode.com/@kakallatt)

[Feb 22, 2022](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42/comment/62148a5695c64c6eda455e36#reply-621531461543b38e7605cc18)

[Stefan Olaru](https://hashnode.com/@stefanolaru)

Thank you for the quick reply. I got a new error:

`darwin-x64' binaries cannot be used on the 'linux-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'linux-x64' platform.`

Do you know how to fix it?

[Richathon](https://hashnode.com/@zozoname)

[Feb 26, 2022](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42/comment/62148a5695c64c6eda455e36#reply-621a06f745bf7fc41cc9ba04)

[DK](https://hashnode.com/@kakallatt)

Please refer this one: [github.com/lovell/sharp/issues/2443](https://github.com/lovell/sharp/issues/2443)

The error message suggests node\_modules was populated by running npm install on macOS/Darwin, which won't work on Linux. Make sure you're not sharing or copying an external node\_modules within the Linux container.

\=> It means that we should delete node\_modules and run npm install in linux os not macos

[DK](https://hashnode.com/@kakallatt)

[Mar 21, 2022](https://hashnode.com/posts/on-the-fly-image-resizing-with-aws-lambda-s3-and-cloudfront/61124f7efab8db0c4fc31a42/comment/62148a5695c64c6eda455e36#reply-6238df3f6622115cc80487c5)

[Richathon](https://hashnode.com/@zozoname) Thank you for your reply. So I need a machine running Linux to re-compile the script to make the Lamda function work? I am using macOS right now, but I didn't run npm install. I just downloaded the zip file and upload it to Lamda.
