LOADING...

HOW TO UPLOAD NODE JS APPLICATION TO LAMBDA VIA S3

HOW TO UPLOAD NODE JS APPLICATION TO LAMBDA VIA S3

S3 upload is recommended for lambda functions with a size > 10 Mb of the final deployment package by AWS, However it is a MUST for size ≥ 50 Mb for the final deployment package, Reference to lambda upload restrictions using direct upload of final deployment package

Here are the steps that are to be followed to upload to lambda via S3 :

Step-1: Log in to the AWS management console and under services select S3 and select create bucket

Step-2: Once the bucket is created select the bucket and select upload

Step-3:Browse to where your .zip file is located in your system (Note: It must contain all the dependencies required by the program inside the .zip file along with its corresponding package.json file for lambda to execute successfully)

Step-4:After clicking on open click next to go to set permissions and make sure the bucket has read and write access so lambda can access the bucket and its data when required

Step-5: Click upload

Step-6 Go to your bucket,Select the .zip file as shown and copy its object URL onto your clipboard,This will be used in Step-10

Step-7: Go to services,Select lambda and then create function

Step-8: Click on your newly created lambda function scroll down under configuration and look for Execution role,Under that make sure you use a role which has S3 read and write access(Refer to this link)

Step-9: Now scroll up to Function code and select Code entry point and under that select Upload file from S3

Step-10: Paste the S3 object URL and click save

Step-11: Run your lambda function

Conclusion:

This is the best practice to upload your code to lambda when code size is ≥ 10 Mb since S3 provides a more stable upload and lambda can access your application using the internal amazon network

Leave a Reply

Your email address will not be published. Required fields are marked *

wpChatIcon