AWS API Gateway for wizard¶
You can connect the Wallarm Edge node to Amazon API Gateway to automatically build an API inventory from real traffic.
This connector does not inspect or block malicious requests. Instead, it uses a Lambda function to monitor CloudWatch logs from API Gateway, parse the log data, and forward relevant metadata to a Wallarm Native Node. The result is your API inventory.
Follow the steps below to set up the connection.
1. Create an IAM role with an IAM policy for Lambda
-
Sign in to the AWS Management Console and go to Identity and Access Management (IAM).
-
Create the following IAM policy using the JSON editor:
-
Go to Roles and click Create role.
-
Select AWS service and Lambda for "Trusted entity type" and "Use case", respectively, and then click Next.
-
On the "Add permissions" step, select the IAM policy you have created earlier, and click Next.
-
Give your IAM role a recognizable name (e.g.,
WallarmAPIDiscoveryLambdaRole) and optionally edit the role's description. -
Click Create role.
2. Create a Lambda function
-
Open the Functions page of the Lambda console and click Create function.
-
Select Author from scratch.
-
Give your function a recognizable name (e.g.,
wallarm-api-discovery-connector). -
Choose Python 3.13 and x86_64 under "Runtime" and "Architecture", respectively.
-
Under "Permissions", expand Change default execution role, select Use an existing role, and then select the IAM role you created in Step 2 (
WallarmAPIDiscoveryLambdaRole) -
Click Create function.
3. Configure the Lambda function
-
Download the code bundle for Amazon API Gateway from the Wallarm Console.
-
Extract the code bundle archive, open the
cw-resend-lambda/lambda_function.pyfile, and copy its contents. -
In your Lambda function, go to the Code tab and paste the copied code into the "Code source" section.
-
Click Deploy.
-
Go to the Configuration tab → Environment variables → Edit.
-
Click Add environment variable and specify the following environment variables for Node communication:
X_NODE_URL- Edge Node DNS name or IP address, including a port if necessary (e.g.,node.example.comor192.0.2.1).X_NODE_SCHEME- set tohttps.
-
Click Save.
-
Go to the Configuration tab → General configuration → Edit.
-
Under "Timeout", set a value sufficient for processing a batch of logs (e.g., 30 seconds to 1 minute).
-
Click Save.
4. Configure CloudWatch API logging using the API Gateway console
-
In the main navigation panel, choose APIs, then click the name of your API.
-
Go to Stages → your stage (e.g.,
prod), scroll down to the Logs and tracing section, and then click Edit. -
Under CloudWatch logs, select Errors and info logs and toggle on Custom access logging.
-
Under Access log destination ARN, specify the ARN of the CloudWatch log group where logs will be written.
If the group does not exist, create it and copy the ARN. The ARN has the following format:
arn:aws:logs:region:account-id:log-group:group-name. -
In the Log format section, paste the following JSON log format (optimized to include only essential fields):
{ "requestId": "$context.requestId", "httpMethod": "$context.httpMethod", "path": "$context.path", "protocol": "$context.protocol", "status": "$context.status", "responseLength": "$context.responseLength", "requestTime": "$context.requestTime", "requestTimeEpoch": "$context.requestTimeEpoch", "responseLatency": "$context.responseLatency", "integrationLatency": "$context.integrationLatency", "integrationStatus": "$context.integrationStatus", "errorMessage": "$context.error.message", "stage": "$context.stage", "domainName": "$context.domainName", "sourceIp": "$context.identity.sourceIp", "userAgent": "$context.identity.userAgent" } -
Click Save.
5. Connect CloudWatch Logs to Lambda (subscription filter)
-
Go to CloudWatch Console → Logs → Log groups.
-
Find and select the log group you have specified in the API Gateway console in Step 3.
-
Click Actions → Subscription filters → Create Lambda subscription filter.
-
Select the Lambda function you have created in Step 3 (e.g.,
wallarm-api-discovery-connector). -
Under "Log format", select JSON.
-
You can leave "Subscription filter pattern" empty or configure filtering if necessary.
-
Under "Subscription filter name", specify a filter name (e.g.,
WallarmFilter). -
Click Start streaming.
By completing this step, you have linked the API Gateway log group to the Lambda function. The function will now start receiving and processing log events.
6. Check the API Discovery inventory
If the AWS infrastructure was deployed correctly, the API Discovery feature is automatically enabled.
Generate traffic to your API endpoints (e.g., using curl) to build the API inventory and populate the API Discovery dashboard.
Wallarm builds the API inventory only after receiving a sufficient number of requests for each endpoint.