Horje
How to Duplicate an AWS Lambda Function

AWS Lambda is a serverless computing technology made by Amazon Web Services, that allows one to run a piece of code without any need of maintaining a server. This makes it an ideal choice for various applications, from simple task automation to complex backend services. However, there may be a need to duplicate a lambda function, for any reason, be it testing or version control, etc. In this article, we will see how to duplicate a lambda function.

Though there is no specific one-button click process to duplicate a lambda function, it can be achieved by following these steps.

How to Duplicate an AWS Lambda Function: Step-By-Step Process

Step 1: Login into your AWS Console

Step 2: Go to the Lambda Dashboard

Type “Lambda” inside the search box located inside the top left corner.

Lambda

Step 3: Select the function to duplicate After heading into the AWS Lambda web page, you will see a list of Lambda Functions which you have created. Select the one that you want to duplicate. I want to duplicate my TestLambda function from my list of Lambda Functions. So i will left-click on the function and head inside it.

Functions

Step 4: Note down the function’s configurations. When you are inside your Lambda Function, scroll down and note down the runtime configuration.

Runtime settings

Here, my runtime configuration is ‘Python 3.12’ and Architecture is x86_64. Then head into Configurations tab and note the other details such as timeouts, memory triggers, permissions etc.

General configuration

My lambda function does not require any specific permissions and triggers as its only for demonstration, but if your lambda function has any specific permissions and triggers or any other thing, please note it down, as you may want to add it to the duplicate function as well.

Step 5: Download the Code

After noting down all the important configurations, download the function code.

Scroll up and you will see a download option in the top-right corner of the Function Overview Box.

Click on the Download button and select Download function code .zip file.

functions overview

After successfully downloading the function code, we are ready to duplicate this function.

Step 6: Create a new Lambda Function

Go to the Lambda home page and select the Create Function Button.

create function

Step 7: Select Runtime and Architecture

Once inside the create function page, give your duplicate function any name. Give it the same runtime and architecture which you noted down earlier.

For me it was Python 3.12 and x86_64 architecture.

Select the Create Function button.

basic function

Step 8: Configure the new function

  1. Go into the configuration tab of the new function
  2. Update the configuration settings of the new function to match the old function
  3. Update its Timeout settings, permissions, triggers, etc.

Step 9: Upload the .zip file

After successfully completing the above steps, upload the .zip file downloaded previously into the new Lambda function’s code.

Inside the code tab of the lambda function, Select the Upload button from the top right corner and then select .zip file

Upload the downloaded file into your new lambda function

test

Step 10: Test your new function.

Test your duplicate lambda function if its working as expected or not. If not, check the configuration settings again and correct if any mistake is present.

Conclusion

There is no specific one click button to duplicate a lambda function but it can be duplicated if one follows the some series of steps properly. Duplicating a lambda function may provide several benefits such as Testing new features, Backup and Recovery, Simplified Management, etc.

Duplicate an AWS Lambda Function – FAQs

Why to Duplicate a lambda function?

One may need to duplicate a lambda function to ensure proper backup and recovery, or for testing new features, etc.

Can the function be duplicated using AWS CLI

Yes, the function can be duplicated using AWS CLI by following the same steps as stated above.

How can I ensure that the new function has the same permissions as the original?

One can ensure the function has the same permissions by ensuring both have the same IAM roles.




Reffered: https://www.geeksforgeeks.org


Amazon Web Services

Related
Building a Data Lake on AWS with Terraform Building a Data Lake on AWS with Terraform
How to Install AWS Lambda in Visual Studio Code How to Install AWS Lambda in Visual Studio Code
How to Install Docker on Amazon Linux How to Install Docker on Amazon Linux
S3 Standard vs Intelligent Tiering – What’s the difference S3 Standard vs Intelligent Tiering – What’s the difference
Use high-level (s3) commands with the AWS CLI Use high-level (s3) commands with the AWS CLI

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
16