> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Handlers on AWS Lambda

> Deploy a target handler as an AWS Lambda function behind a function URL.

1. Write the [handler](https://docs.bijection.com/functions/targets.md#write-the-handler), then export a
   Lambda handler beside it:

   ```ts lambda.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
   import { lambda } from "@bijectionhq/target-handler/lambda";
   import score from "./handlers/score";

   export const handler = lambda(score);
   ```

2. Bundle it for Node, for example with
   `esbuild lambda.ts --bundle --platform=node --target=node22 --outfile=dist/index.js`.

3. Create the function (Node.js 22) from `dist/index.js` with the handler
   `index.handler`, and add a function URL with auth type `NONE`. Bijection
   authenticates with the token in the binding's `credential`, not with IAM.

4. Set the token and give the function the same value:

   ```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
   bijection secret set scoring.score.token
   aws lambda update-function-configuration --function-name score \
     --environment "Variables={BIJECTION_TARGET_TOKEN=<the same value>}"
   ```

5. Bind the target to the function URL in the installation's bindings file, then deploy:

   ```ts bindings.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
   import { placement } from "@bijectionhq/bijection";
   import app from "./bijection/app";
   const { bind, endpoint, env, bindings } = placement;

   export default bindings([
     bind(app.scoring.score, endpoint({
       url: env("SCORING_URL"), hosts: ["<id>.lambda-url.<region>.on.aws"], credential: "scoring.score.token",
     })),
   ]);
   ```

   Set `SCORING_URL` with `bijection env set SCORING_URL <url>` before deploying. Replace the example host with the exact host returned by your provider.

Set the function's timeout at or above the target's `within`. A request that
times out settles the task `Unknown`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.