Skip to main content

AWS Lambda

Manage your AWS Lambda's: invoke them, create new ones, update, delete, and much more...

Tagsawsserverlessfunction

Credential configuration

To configure this credential, you need the Access Key ID and the Secret Access Key of the Programatic access user you want to use. Make sure this user has the required permissions to access Lambda to work properly. If you need to create the user, follow the instructions provided here.

In the extra options field, you can include any of the parameters found here.

Here is an example of a filled credential configuration form in YepCode:

AWS Lambda Snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script.

Integration

New integration from credential
const awsLambdaClient = yepcode.integration.awsLambda("credential-slug");
New integration from plain authentication data
const { LambdaClient } = require("@aws-sdk/client-lambda");

const awsLambdaClient = new LambdaClient({
credentials: {
accessKeyId: "accessKeyId",
secretAccessKey: "secretAccessKey",
},
});

List Functions

List functions
const { ListFunctionsCommand } = require('@aws-sdk/client-lambda')
const listFunctionsCommand = new ListFunctionsCommand({});

const { Functions } = await awsLambdaClient.send(listFunctionsCommand);
for(const func of Functions) {
console.log(func.FunctionName, func.Description)
}

Invoke Function

Invoke function
const { InvokeCommand, LogType } = require('@aws-sdk/client-lambda')

try {
const params = {
FunctionName: 'funcName',
Payload: JSON.stringify({ foo: 'bar' }),
LogType: LogType.Tail
}
const invokeCommand = new InvokeCommand(params)
const { Payload, LogResult } = await awsLambdaClient.send(invokeCommand)
const result = Buffer.from(Payload).toString()
const logs = Buffer.from(LogResult, 'base64').toString()

console.log(result)
console.log(logs)
} catch (error) {
throw error
} finally {
// if you are using a custom http handler, you may call destroy() to close open connections.
client.destroy()
}

Get Function

Get function
const { GetFunctionCommand } = require("@aws-sdk/client-lambda");
const getFunctionCommand = new GetFunctionCommand({ FunctionName: 'funcName' });
const response = await awsLambdaClient.send(getFunctionCommand)
console.log(response);