Resize Images with Node.js and AWS Lambda (and S3)

  Рет қаралды 12,233

Nikita Dev

Nikita Dev

Күн бұрын

In this video you'll learn how to create, modify, deploy, and test an AWS Lambda. I will show you how to set permissions through IAM roles/policies, and also how to set up S3 triggers to invoke your Lambda when an image is uploaded to a bucket. We will use the Sharp NPM package to easily resize images, and the AWS S3 SDK to interact with our buckets.
Code: github.com/nik...
Sharp NPM: www.npmjs.com/...
Guide: docs.aws.amazo...
Github: github.com/nik...
Support Me: www.buymeacoff...
Contact Me: nikitadev292@gmail.com
#nodejs #aws #javascript

Пікірлер: 44
@ricksegalCanada
@ricksegalCanada 4 ай бұрын
Thanks for taking the time to do this video. Your explanation style is excellent as all too often youtubers forget we don't know and they forget to explain things properly. Well done.
@hmvarshney5222
@hmvarshney5222 4 ай бұрын
Great course! Simple and to-the-point, unlike others.
@cheey3839
@cheey3839 11 ай бұрын
Thank u!!! Yours is the most up to date tutorial, with details.
@vjself
@vjself 7 ай бұрын
I couldn't actually get this to work following your video (sharp really does have some issues running in lambda) but cloning your repo and adjusting the code to my needs did the trick. Thank you so much for this it was incredibly helpful!
@DeveloperDsb
@DeveloperDsb 6 ай бұрын
@vjself did you created your own function.zip file? if yes, could you please tell me how u did this because I tried to do so by running the command npm run package but I am getting the error "PS C:\Users\Dell\Desktop\Lambda_function\image-resizer-lambda> npm run package > thumbnail-generator-lambda@1.0.0 package > zip -r function.zip . 'zip' is not recognized as an internal or external command, operable program or batch file."
@R.Yuvashri
@R.Yuvashri 3 ай бұрын
Did you found the solution... Im still stucked in it
@Adityabalaji-qv4nx
@Adityabalaji-qv4nx 17 күн бұрын
Excellant training sir
@brunolaranjeira3855
@brunolaranjeira3855 10 ай бұрын
Amazing work my friend. Your code worked like a charm. Only thing I changed was to hardcode the destination Bucket instead of using ENV variables. Thank you from Brazil.
@aleksey6151
@aleksey6151 Жыл бұрын
goated tutorial
@gianfrancoperaltabravo6004
@gianfrancoperaltabravo6004 2 ай бұрын
Amazing video !
@sahebdhara1286
@sahebdhara1286 7 ай бұрын
The deployment package of your Lambda function "lamda-for-image-resize" is too large to enable inline code editing. However, you can still invoke your function.
@alexander_ci
@alexander_ci 6 ай бұрын
One way around this is using a Lambda layer and pointing your dependencies to that Layer, then that normally makes it a much smaller package.
@vigneshtamizh4091
@vigneshtamizh4091 6 ай бұрын
Store the zip file in S3 bucket and provide the S3 object url in lambda upload
@WriteCodeWithMaan
@WriteCodeWithMaan 4 ай бұрын
How can we access the sharp library without adding any dependency or without adding any layer to lambda? How your lambda function is reading the sharp library?
@lucasfranzolin
@lucasfranzolin 2 ай бұрын
do you know why exactly I keep getting "sharp module not found"? I'm even zipping the node_modules
@sammunroe389
@sammunroe389 7 ай бұрын
Great tutorial. I am running into one snag. Whenever I extract the function zip, modify index.js to 400px instead of 200px, re-zip, and upload....it tells me it can't find module 'index'
@sammunroe389
@sammunroe389 7 ай бұрын
Figured it out! Don't zip the functions parent folder. Select all files and zip, to a new zipped folder. Very strange but it fixed it.
@nikita-dev
@nikita-dev 7 ай бұрын
thanks for sharing!
@vvyael
@vvyael 7 ай бұрын
Amazing
@Matt6176
@Matt6176 7 ай бұрын
Hello and thank you for this tutorial! Could you please explain what the purpose of the package-lock.josn file is? Will the function run without it? Thank you!
@nikita-dev
@nikita-dev 7 ай бұрын
The package-lock file just stores the versions of all of the dependencies in your package json at the point of installation. I would not recommend removing this file.
@harshal_joshi
@harshal_joshi 4 ай бұрын
9:02 i have a error like zip' is not recognized as an internal or external command
@harshal_joshi
@harshal_joshi 4 ай бұрын
Please reply me
@ChadDiaz-qk4fb
@ChadDiaz-qk4fb 4 ай бұрын
@nikita-dev - I'd like to set something like this up but will take an original image and output a web image, mobile image and thumbnail image. Can you assist how to do this?
@nikita-dev
@nikita-dev 4 ай бұрын
After you fetch the original image in S3, you need to run the Sharp resize function 3 times, passing in your desired widths for web, mobile & thumbnail. Then you’ll need to save off those 3 images in your output bucket, with their sizes included in the key.
@hashimali4262
@hashimali4262 8 ай бұрын
Great work. Ok I have a question when we upload image from frontend via post request it get stored in s2 and lambda function get triggered and image converted and stored to another s3 bucket. Now I want to send the converted image back as response to the user how I may able to do it? as my flask python coed will not wait for the completing of conversion in lambda
@nikita-dev
@nikita-dev 7 ай бұрын
you would probably need to implement polling (on the bucket that stores resized images).
@regilearn2138
@regilearn2138 Жыл бұрын
can u show us how to save/upload image/multiple image in s3 bucket with lambda function in react app,
@nikita-dev
@nikita-dev 11 ай бұрын
I made a similar video to this already: kzbin.info/www/bejne/rIeloniPg72rr5o
@tomscall3811
@tomscall3811 10 ай бұрын
So that's it with the Lambda code :). I have the feeling that I have to rewrite my whole app just to make it run on Lambda. Or is there an easy way? I use multer-sharp-s3 in my app, where everything is stored in an S3 bucket. Everything works great locally. But there are problems on Lambda. How can I get it to run. What additional code do I need for Lambda?
@nikita-dev
@nikita-dev 7 ай бұрын
It might be a permissions error (make sure the lambda has access to the right buckets). Also check the lambda logs for specific errors
@tomscall3811
@tomscall3811 7 ай бұрын
@@nikita-dev Thank you very much. I didn't understand the function of Lambda back then. I wanted to publish an entire app, which led to problems. I then switched to Elastic Beanstalk
@vikramadityasinghai5968
@vikramadityasinghai5968 10 ай бұрын
If i was to do this using python, which library could i use ???????/
@nikita-dev
@nikita-dev 7 ай бұрын
Pillow is a popular python library for this
@anirudh5101
@anirudh5101 6 ай бұрын
Can anyone tell me is this project worth putting In my resume. Im just a beginner and pursuing my masters right now
@Benjamin-Chavez
@Benjamin-Chavez 5 ай бұрын
maybe as part of a larger project, but not necessarily by itself. (just my opinion)
@anirudh5101
@anirudh5101 5 ай бұрын
@@Benjamin-Chavez Thanks Benjamin 😄
@Kimitri
@Kimitri 10 ай бұрын
why use 2 separate buckets?
@nikita-dev
@nikita-dev 10 ай бұрын
mainly to avoid any chance of recursive invocations. if you go to 11:33 I talk a little bit about that.
@Kimitri
@Kimitri 10 ай бұрын
That makes sense. Thank you for replying to me.
@Kimitri
@Kimitri 10 ай бұрын
​@nikita-dev I have another question, my application is for an photo studio, and the employees gonna upload more than 1000 photos for each album. The select all the photos and click in upload, I need to do some configuration on lambda function to works with it with no problems?
@quanne131
@quanne131 8 ай бұрын
can you make i video about deploy nodejs app to aws free
@MaryamArshad-k2s
@MaryamArshad-k2s 11 ай бұрын
Hi! When i test the event i got error as Response { "errorType": "Runtime.ImportModuleError", "errorMessage": "Error: Cannot find module 'index' Require stack: - /var/runtime/index.mjs", "trace": [ "Runtime.ImportModuleError: Error: Cannot find module 'index'", "Require stack:", "- /var/runtime/index.mjs", " at _loadUserApp (file:///var/runtime/index.mjs:1087:17)", " at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)", " at async start (file:///var/runtime/index.mjs:1282:23)", " at async file:///var/runtime/index.mjs:1288:1" ] }
@rassdsign8788
@rassdsign8788 9 ай бұрын
Hi the reason you got that error is because you zip the folder instead you should directly zip the file so that when you open zip file it directly can read index.js.
Storing Images in S3 from Node Server
39:59
Sam Meech-Ward
Рет қаралды 93 М.
Developing AWS Lambda Functions Locally in VS Code
20:22
Travis Media
Рет қаралды 124 М.
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 236 МЛН
POV: Your kids ask to play the claw machine
00:20
Hungry FAM
Рет қаралды 21 МЛН
How to Use AWS S3 with NodeJS?
30:39
Piyush Garg
Рет қаралды 49 М.
Develop Lambdas Locally in VS Code Using AWS SAM | AWS Lambda Tutorial
15:50
How to Run a Python Docker Image on AWS Lambda
13:08
pixegami
Рет қаралды 33 М.
Upload Images with React & Node JS  to AWS S3
42:18
Nikita Dev
Рет қаралды 19 М.
AWS Serverless Demo - Resizing S3 Images With AWS Lambda Trigger
34:26
Serverless Framework with AWS Lambda Crash Course
1:29:11
Laith Academy
Рет қаралды 111 М.
Managing dependencies using AWS Lambda Layers with NodeJS and AWS SAM
20:42
Error Handling in NodeJS (Complete Guide) | Node Tutorial
17:54
Nikita Dev
Рет қаралды 42 М.
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 236 МЛН