Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy or duplicate an AWS Lambda function

I have an AWS Lambda function that is triggered from an API Gateway API. I want to duplicate this Lambda function including the triggers. How can I do this? I tried using "create version" but the API Gateway trigger is not duplicating and I am not able to change the code.

like image 707
Rajarshi DAs Avatar asked May 24 '18 13:05

Rajarshi DAs


People also ask

Can lambda function be reused?

Fortunately, you can assign lambda expressions to variables and reuse them, as you would with objects.

How do I download a lambda function?

Navigate over to your lambda function settings and on the top right you will have a button called " Actions ". In the drop down menu select " export " and in the popup click "Download deployment package" and the function will download in a . zip file. Click on the function.

How do I import a lambda function?

On the Create component page, under Component information, choose Import Lambda function. In Lambda function, search for and choose the Lambda function that you want to import. AWS IoT Greengrass creates the component with the name of the Lambda function. In Lambda function version, choose the version to import.


1 Answers

When editing a lambda function, you can go Actions > Export Function > Download deployment package.

enter image description here

This downloads a .zip file of the function.

Then create a new Lambda, and go "Upload from" (right above the code editor) > ".zip file"

enter image description here

This duplicates the code and npm modules etc... Not the triggers or permissions of the function though.

like image 109
Emmanuel Avatar answered Sep 23 '22 23:09

Emmanuel