aws-lambda
and initialize a new project with
your favourite package manager. This example uses npm
because everyone will
have it installed with node already.
esbuild
to bundle our code, so we can upload it to AWS later.
verify
function for now. We
will add that next. In the handler we will prepare all necessary variables that
we need for verification. This includes the signature, the signing keys and the
url of the lambda function. Then we try to verify the request using the current
signing key and if that fails we will try the next one. If the signature could
be verified, we can start processing the request.
verify
function will handle the actual verification of the signature. The
signature itself is actually a JWT and includes claims about
the request. See here.
Node.js 16.x
as runtime, then create the function.
Configuration
tab:
Auth Type = NONE
because we are handling authentication ourselves.
After creating the url, you should see it on the right side of the overview of
your function: Configuration
tab from earlier, we will now set the required
environment variables: package.json
file:
npm run build
this will build and zip the code.
Afterwards we can click the Upload from
button in the lower right corner and
deploy the code to AWS. Select ./dist/index.zip
as upload file.