sagidm / s3-resizer Goto Github PK
View Code? Open in Web Editor NEWAWS Lambda for resizing images in S3 on fly.
License: MIT License
AWS Lambda for resizing images in S3 on fly.
License: MIT License
I received the following email from AWS - do you intend to rebuild using 10?
Hello,
We are contacting you as we have identified that your AWS Account currently has one or more Lambda functions using Node.js 8.10, which will reach its EOL at the end of 2019.
What’s happening?
The Node community has decided to end support for Node.js 8.x on December 31, 2019 [1]. From this date forward, Node.js 8.x will stop receiving bug fixes, security updates, and/or performance improvements. To ensure that your new and existing functions run on a supported and secure runtime, language runtimes that have reached their EOL are deprecated in AWS [2].
For Node.js 8.x, there will be 2 stages to the runtime deprecation process:
Disable Function Create – Beginning January 6, 2020, customers will no longer be able to create functions using Node.js 8.10
Disable Function Update – Beginning February 3, 2020, customers will no longer be able to update functions using Node.js 8.10
After this period, both function creation and updates will be disabled permanently. However, existing Node 8.x functions will still be available to process invocation events.
What do I need to do?
We encourage you to update all of your Node.js 8.10 functions to the newer available runtime version, Node.js 10.x[3]. You should test your functions for compatibility with the Node.js 10.x language version before applying changes to your production functions.
Hello,
It cannot auto generate smaller images for nested directory.
For example, I have an image at https://gt-sky.s3-ap-southeast-1.amazonaws.com/hongphucsport.vn/b.png
The module cannot give me the image at https://gt-sky.s3-ap-southeast-1.amazonaws.com/hongphucsport.vn/150x150/b.png
Thank you very much.
I can test successful in Lambda , but I test in my chrome brower and the system return "Access Denied". Could help me? Thanks !!
AccessDenied
Access Denied
E6BC853F822F087E
0W84WFaXXRCdQnZa1DWRSzQc0/LRijPbqjqSKf4tejzoXHmwF1nq9c42yWfXJa10i6CWmpBaO88=
ran through the install steps, ran into an issue when running my test:
{ "errorMessage": "The module '/var/task/node_modules/sharp/build/Release/sharp.node'\nwas compiled against a different Node.js version using\nNODE_MODULE_VERSION 48. This version of Node.js requires\nNODE_MODULE_VERSION 57. Please try re-compiling or re-installing\nthe module (for instance, using
npm rebuildor
npm install).", "errorType": "Error", "stackTrace": [ "NODE_MODULE_VERSION 48. This version of Node.js requires", "NODE_MODULE_VERSION 57. Please try re-compiling or re-installing", "the module (for instance, using
npm rebuildor
npm install).", "Object.Module._extensions..node (module.js:681:18)", "Module.load (module.js:565:32)", "tryModuleLoad (module.js:505:12)", "Function.Module._load (module.js:497:3)", "Module.require (module.js:596:17)", "require (internal/module.js:11:18)", "Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:10:15)", "Module._compile (module.js:652:30)", "Object.Module._extensions..js (module.js:663:10)", "Module.load (module.js:565:32)" ] }
Forgive my lack of knowledge on AWS - i'm kind of a newbie but when i try to test the lambda the following gets returned - is there a missing module or do i need to do anything additional to your tutorial? Thank you! Any help is appreciated.
Response:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'sharp'",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'sharp'",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object. (/var/runtime/index.js:45:30)",
" at Module._compile (internal/modules/cjs/loader.js:778:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
" at Module.load (internal/modules/cjs/loader.js:653:32)",
" at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
" at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
" at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)",
" at startup (internal/bootstrap/node.js:283:19)"
]
}
Request ID:
"a9d515ef-c4a3-4b8b-ba30-f8d2c643bc0b"
Function Logs:
START RequestId: a9d515ef-c4a3-4b8b-ba30-f8d2c643bc0b Version: $LATEST
2020-03-31T13:40:02.304Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'sharp'","stack":["Runtime.ImportModuleError: Error: Cannot find module 'sharp'"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object. (/var/runtime/index.js:45:30)"," at Module._compile (internal/modules/cjs/loader.js:778:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)"," at Module.load (internal/modules/cjs/loader.js:653:32)"," at tryModuleLoad (internal/modules/cjs/loader.js:593:12)"," at Function.Module._load (internal/modules/cjs/loader.js:585:3)"," at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)"," at startup (internal/bootstrap/node.js:283:19)"]}
END RequestId: a9d515ef-c4a3-4b8b-ba30-f8d2c643bc0b
REPORT RequestId: a9d515ef-c4a3-4b8b-ba30-f8d2c643bc0b Duration: 763.36 ms Billed Duration: 800 ms Memory Size: 768 MB Max Memory Used: 30 MB
Unknown application error occurred
Runtime.ImportModuleError
Hi!
I've got the resizing working, but Lambda is not working on HTTPS.
I can reach my original (public) S3 image on
https://[bucket].s3.eu-north-1.amazonaws.com/[image].jpg
and
http://[bucket].s3.eu-north-1.amazonaws.com/[image].jpg
And resized via Lambda on HTTP
http://[bucket].s3-website.eu-north-1.amazonaws.com/300x300/[image].jpg
But on on HTTPS
https://[bucket].s3-website.eu-north-1.amazonaws.com/300x300/[image].jpg
That just times out.
Though, when I have used Lambda over HTTP I can reach via HTTPS directly through S3.
Any ideas?
I received the following email from AWS - do you intend to rebuild using 16?
Hello,
We are contacting you as we have identified that your AWS Account currently has one or more Lambda functions using Node.js 12 runtime.
We are ending support for Node.js 12 in AWS Lambda. This follows Node.js 12 End-Of-Life (EOL) reached on April 30, 2022 [1].
As described in the Lambda runtime support policy [2], end of support for language runtimes in Lambda happens in two stages. Starting November 14, 2022, Lambda will no longer apply security patches and other updates to the Node.js 12 runtime used by Lambda functions, and functions using Node.js 12 will no longer be eligible for technical support. In addition, you will no longer be able to create new Lambda functions using the Node.js 12 runtime. Starting December 14, 2022, you will no longer be able to update existing functions using the Node.js 12 runtime.
We recommend that you upgrade your existing Node.js 12 functions to Node.js 16 before November 14, 2022.
I followed readme file and I've done everything that @sagidM said in the readme file.
node version is: 12.x
Handler: index.handler
.zip file: s3-resizer-3.1.0.zip (download zip from your repo.)
Still, I'm getting below error when I run the test.
test json is
{
"queryStringParameters": {
"path": "150x150/engg.jpg"
}
}
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'sharp'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'sharp'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object. (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1015:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)",
" at Module.load (internal/modules/cjs/loader.js:879:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:724:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}
It would be quite annoying if someone was to create various sizes of different images.
Is there a way to white list only a few specific image sizes?
I have one file "https://qooapp-image.s3-ap-southeast-1.amazonaws.com/1.jpg".
when I use https://qooapp-image.s3-ap-southeast-1.amazonaws.com/200x200/1.jpg, it redirect to "https://rjmbvlnp5h.execute-api.ap-southeast-1.amazonaws.com/qooapp-image-resize/qooapp-image-resize/200x200/1.jpg", and say "Missing Authentication Token".
but open "https://qooapp-image.s3-ap-southeast-1.amazonaws.com/200x200/1.jpg" again, it ok.
Great library by the way, it works great in the root of the buckets ,
but when i created folder inside the backet and upload new image to this sub folder when i tried to resize it using the fill path
https://lockcommerce.s3.me-south-1.amazonaws.com/187hdk3783-34345/50x50/img.png
the sub folder name : 187hdk3783-34345 ( cause i want to create folder for each customer .
i received this error
AccessDenied
Access Denied
F59E7CC0FF72CEA3
5L5me6BP8S9Xk8qH9XeYBk1WvXobMz91MO/oCDVlXgad+5bgG7/CWWPy+C1dlk5IOpB4YctAWbY=
please help .
Hello,
The Lambda function is working well, but I have cyclic redirect when trying to configure it with CloudFront.
I created a CloudFront distribution with default settings and used S3's static website endpoint as the origin. Also, I used the CloudFront domain name for the URL
Lambda envonment variable.
Existing images are served well. But for new images I receive redirects loop between API gateway and CloudFront. What is interesting, new image generated and accessible with S3's endpoint. Can't get what is wrong.
Any ideas on how to fix it?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.