Setting up a Lambda
The AWS CDK is the most convenient way to create a new project on AWS Lambda. For example, it lets you directly define integrations such as APIGateway, a tool to make our lambda publicly available as an API, in your code.Terminal
Webhook verification
Using the SDK (recommended)
Editlambda/index.ts
, the file containing our core lambda logic:
lambda/index.ts
QSTASH_CURRENT_SIGNING_KEY
and QSTASH_NEXT_SIGNING_KEY
environment variables together when deploying our Lambda.
Manual Verification
In this section, we’ll manually verify our incoming QStash requests without additional packages. Also see our manual verification example.- Implement the handler function
lambda/index.ts
- Implement the
verify
function:
lambda/index.ts
Deploying a Lambda
Using the AWS CDK (recommended)
Because we used the AWS CDK to initialize our project, deployment is straightforward. Edit thelib/<your-stack-name>.ts
file the CDK created when bootstrapping the project. For example, if our lambda webhook does video processing, it could look like this:
lib/<your-stack-name>.ts
Terminal

https://<API-GATEWAY-ID>.execute-api.<API-REGION>.amazonaws.com/prod/
To provide our QSTASH_CURRENT_SIGNING_KEY
and QSTASH_NEXT_SIGNING_KEY
environment variables, navigate to your QStash dashboard:


Manual Deployment
- Create a new Lambda function by going to the AWS dashboard for your desired lambda region. Give your new function a name and select
Node.js 20.x
as runtime, then create the function.

- To make this Lambda available under a public URL, navigate to the
Configuration
tab and clickFunction URL
:

-
In the following dialog, you’ll be asked to select one of two authentication types. Select
NONE
, because we are handling authentication ourselves. Then, clickSave
. You’ll see the function URL on the right side of your function overview:

- Get your current and next signing key from the Upstash Console.

- Still under the
Configuration
tab, set theQSTASH_CURRENT_SIGNING_KEY
andQSTASH_NEXT_SIGNING_KEY
environment variables:

- Add the following script to your
package.json
file to build and zip your code:
package.json
- Click the
Upload from
button for your Lambda and deploy the code to AWS. Select./dist/index.zip
as the upload file.

Testing the Integration
To make sure everything works as expected, navigate to your QStash request builder and send a request to your freshly deployed Lambda function:
Terminal