Search code examples
javascriptnode.jsaws-lambdadependencies

Add dependency on existing AWS lambda function for nodejs


I want to update my AWS lambda function that is already deployed to AWS.

The lambda is a nodejs function

It has a javascript, package.json and package-lock.json

There is no code or steps that I can find to help with that is clear steps on AWS docs.

I looked for them but I get how to create a function.

Also to be noted I do not have the original code on git or anything. What I have is in the lambda function.

I also need to install an npm package to the function as part of updating.


Solution

  • You can use GetFunction get the function details which will give you path of s3 from which you can download the code. More details - https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#getFunction-property

    For Updating the function code use UpdateFunctionCode - https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#updateFunctionCode-property

    For Updating function configuration use UpdateFunctionConfiguration - https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#updateFunctionConfiguration-property