> This page is for Applications Protection.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.humansecurity.com/llms.txt.

# Installation

If your organization uses AWS HTTP API Gateway with a NodeJS Lambda integration, you can use the HUMAN API Gateway Enforcer to protect your API Gateway against malicious behavior. The HUMAN enforcer easily integrates into your existing AWS Lambda function.

### Prerequisites

* An existing [AWS HTTP API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html)
* A [NodeJS Lambda integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html) with Node v16.x or later.

> **Note**
>
> For the HUMAN AWS HTTP API Gateway Enforcer to be compatible with your AWS Lambda function integration, the AWS Lambda function must use [v2 of the payload format structure](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format).

### Installation

1. Install the Enforcer using NPM package in your project.

```bash
npm install @humansecurity/aws-api-gateway-enforcer
```

2. Save your handler in a constant

```typescript
import { APIGatewayProxyEventV2 } from 'aws-lambda';

const myHandler = (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyStructuredResultV2> => {
    // ... original lambda handler code
}
```

3. Export HUMAN Security's handler from your Lambda.

```typescript
import { handler as humanSecurityHandler } from "@humansecurity/aws-api-gateway-enforcer";

const pxConfig = {
    onPass: myHandler,
    px_app_id: "<APP_ID>",
    px_cookie_secret: "<COOKIE_SECRET>",
    px_auth_token: "<AUTH_TOKEN>"
    // ...
};
export const handler = humanSecurityHandler(pxConfig);
```

4. Deploy the AWS Lambda function and API Gateway.