Invoke an AWS Lambda Function from a Web Hook
Webhooks by Zapier + AWS Lambda
Before you start - you need to create an IAM user that has limited permissions to Lambda only. You should follow these instructions remembering to substitute "Lambda" for "SES".
There are two ways to use AWS Lambda with Zapier:
This is the simplest but more strict option via the Invoke Function action - you tell us which function you want us to invoke and we'll provide the data to invoke it. You will write your code in the Amazon console or whatever medium you prefer.
This is a more flexible option that allows you to write code in your browser during Zap setup via the Run Code action - though you will need to upload a special "sugar" function that takes both data and the code you wrote during Zap setup. The special "sugar" function simply
evals the code as a convenience.
This is the Invoke Function action. This presumes you have a pre-built function that you just want Zapier to invoke with some special arguments or data we provide from a trigger. Return data is ignored.
Invoking a Lambda function from Zapier is simple. First select your region, and choose the function to invoke:
Then, provide the arguments that you want to be provided to your function when it is invoked - you'll access it as the
event object you may recognize from the AWS Lambda documentation.
To add more arguments, use the
+ button. A function you would upload to AWS Lambda to consume this event might look something like:
Note - if you are using Java or some other runtime - you may need to deserialize the payload/event as it could be passed in as a JSON bytestring. This is done for you automatically in the Node.js runtime.
This is the Run Code action. It lets you write code in your browser during Zap setup but run the code in your AWS Lambda on behalf of Zapier:
In order for Zapier to "Run Code" dynamically provided in your zap you will need to create a special "sugar" function for us to piggyback. Go to your Lambda Console to get started on this and Create a Lambda Function:
Copy the code from this gist and paste it into your function - be sure to name the function
zapier_eval! This bit of code will let us provide code that is run safely within your very own Lambda environment.
You can set the function's role, memory and timeout to whatever settings you deem appropriate.
Now you can use the "Run Code" action in Zapier and provide code on the fly. You only need to set up this function once - we'll always use it in the future.
You are welcome to customize the
zapier_eval function - some people like to create their own
*.zip with custom npm dependencies so you can
require and utilize other functionality. You are welcome to use the code from this gist as the foundation.
Webhooks by Zapier + AWS Lambda
Schedule by Zapier + AWS Lambda
PagerDuty + AWS Lambda
Slack + AWS Lambda
That is currently not possible with our AWS Lambda integration. Please contact support to be notified if we are able to add this in the future.
As an alternative, you might want to create a second Zap, using a Webhook trigger, and have your function send a request there, to continue the workflow with a new Zap.
Get started with a Free account