AWS Builder Center

AWS Lambda Web Functions Through the AWS Console - Part 1

AWS Lambda Web Functions Through the AWS Console - Part 1

Series: Financial Service (33 articles)

  1. …
  2. 26
    AWS Lambda Web Functions Through the AWS Console - Part 1 This article
Dev @ Vertex Macro

Private Market-Making and Hedge Fund Performance Review API

Audience: trader-developers, trading desk technology leads, cloud architects, risk teams, and compliance reviewers Primary Region used in this guide: Asia Pacific (Hong Kong),  ap-east-1  Backend: AWS Lambda Web Functions with Node.js and Express Landing page: private Amazon S3 origin delivered through Amazon CloudFront Data store: Amazon DynamoDB Authentication: Amazon Cognito user pool for named trading-desk users Operations: Amazon CloudWatch, AWS CloudTrail, AWS WAF, AWS KMS, and AWS Secrets Manager where external credentials are required



Business scenario

A trader wants a tailored API endpoint for a small, approved group of trading-desk and sell-side partner users. The application supports market-making situational awareness and a consolidated review of hedge fund exposure and performance.
The application exposes the following groups of analytics.

Fund Management Metrics

  • Metric: Top Holdings Purpose: Show the underlying equity positions driving concentration Related terms: Portfolio Concentration, Whale Rocking, Top 10 Exposure, Asset Allocation Weights
  • Metric: Largest Trades Purpose: Show significant changes in position sizing Related terms: Form 13F Positions, Discretionary Turnover, Block Trades, Liquidation Events
  • Metric: Portfolio Structure Purpose: Show how capital is distributed across sectors, vintages, and risk layers Related terms: Vintage Diversification, Sector Exposures, Cap Table Sizing, Liquidation Preferences

Fund Performance Analytics

  • Metric: Performance History Purpose: Evaluate cumulative and trailing fund performance Related terms: Net Asset Value, TVPI, J-Curve Progression, IRR
  • Metric: Situational Awareness Performance History Purpose: Track active capital deployment and drawdown behavior during macro changes Related terms: Dry Powder Velocity, Drawdown Mitigation, Vulnerability Stress Testing, Mark-to-Market Realism
  • Metric: Performance vs S&P 500 Purpose: Compare active performance with a passive benchmark Related terms: Alpha Capture, Tracking Error, Relative Return Profiles, Beta-Adjusted Spread
  • Metric: AUM Reported to SEC Purpose: Maintain a regulatory baseline for legally managed assets Related terms: Form ADV Part 1A, RAUM, Compliance Reporting Thresholds, Gross Asset Valuation

What “real time” means here

Use real-time or near-real-time data only from licensed market-data feeds and approved internal systems. Separate these timestamps in every response:
  •  marketDataAsOf : timestamp supplied by the licensed market-data source.
  •  positionsAsOf : timestamp of the authoritative position snapshot.
  •  valuationAsOf : timestamp of the latest approved valuation.
  •  regulatoryDataAsOf : filing date or accession date for Form 13F or Form ADV data.
  •  calculatedAt : time that the API calculated the response.
Never merge delayed regulatory filings with live positions without an explicit status label. Form 13F is a historical holdings disclosure, while Form ADV RAUM is a regulatory baseline. Neither is a live hedge fund portfolio feed.



Why AWS Lambda Web Functions fits this use case

AWS Lambda Web Functions runs a conventional HTTP server and supports familiar Node.js web frameworks such as Express and Hono without Lambda-specific adapters. Lambda creates the HTTPS endpoint, manages execution environments, and scales the application with traffic, including scaling to zero while idle. A Web Function consists of immutable revisions and one or more HTTPS endpoints. See  AWS Lambda Web Functions overview .
This is useful for a small trading-desk API because:
  • the desk can run an Express API directly;
  • no EC2 instance, container host, operating-system patching, or always-on application server is required;
  • the application remains within AWS;
  • immutable revisions make rollback and controlled production promotion practical;
  • a simple landing page can be stored in S3 and delivered securely through CloudFront;
  • CloudWatch and CloudTrail provide operational and administrative evidence.
AWS Web Functions require a ZIP deployment package in an S3 bucket with versioning enabled. Lambda pins each revision to an exact S3 object version, which makes the deployment reproducible. The uncompressed package can be up to 512 MB. See  Deploying Web Function code from Amazon S3 .



Recommended architecture

The recommended request path begins when an approved trader or sell-side partner opens the application in a browser. The browser connects over HTTPS and the user signs in with Amazon Cognito using multifactor authentication. Amazon CloudFront provides the delivery layer, while AWS WAF inspects and controls incoming requests.
CloudFront serves the simple landing page from a private Amazon S3 bucket. Requests for API paths are directed to the AWS Lambda Web Function endpoint. The Web Function uses a temporary IAM execution role to access the DynamoDB tables that contain approved fund metric snapshots.
The Web Function sends logs and operational metrics to Amazon CloudWatch. AWS KMS encrypts protected resources, while AWS Secrets Manager stores credentials for approved external market-data or regulatory-data providers when those credentials are required. AWS CloudTrail records administrative activity, including deployment, identity, policy, and endpoint changes. AWS Security Hub and Amazon GuardDuty are recommended for consolidated security findings and threat detection.

Production decisions

  1. Use CloudFront rather than the S3 website endpoint. Keep S3 Block Public Access enabled and use CloudFront origin access control. AWS documents this as the secure static website pattern:  Get started with a secure static website .
  1. Do not expose an application-managed endpoint without authentication. For a browser application, implement Cognito JWT validation in Express. For server-to-server partners, prefer IAM authentication and SigV4/SigV4a signing or place API Gateway in front when API keys, usage plans, request validation, or richer authorization are required.
  1. Use a Home-Region endpoint initially. Select  ap-east-1  for Hong Kong users and data residency unless the firm's policy requires another approved Region. Home-Region is the simplest endpoint type. The endpoint type cannot be changed after creation.
  1. Use DynamoDB for metric snapshots and precomputed responses. Avoid calculating an entire portfolio from raw trades on every request. Precompute and validate desk summaries upstream.
  1. Do not store secrets in code or ordinary environment variables. Store vendor API credentials in Secrets Manager and encrypt secrets, S3 objects, logs, and DynamoDB tables with KMS keys approved by the firm.



Prerequisites

AWS account and governance

Before starting, confirm:
  • the AWS account is inside the firm's AWS Organizations structure;
  • CloudTrail organization trails and central logging are enabled;
  • the Hong Kong Region is enabled for the account;
  • service control policies allow Lambda Web Functions, S3, DynamoDB, CloudWatch, Cognito, CloudFront, WAF, KMS, and Secrets Manager;
  • an IAM administrator has granted the builder permissions to manage Web Functions, pass an execution role with  iam:PassRole , and use the deployment S3 bucket;
  • production and non-production environments use separate accounts where possible.
The AWS console can create or reuse the execution role and deployment bucket. For production, create and review both resources explicitly. AWS lists the Web Function prerequisites in  Creating a Lambda Web Function .

Naming convention used below

Replace  123456789012  and all globally unique bucket names with your values.
  • Resource: Web Function Example name:  fsi-market-maker-review-api 
  • Resource: Endpoint Example name:  prod-hk 
  • Resource: Code bucket Example name:  fsi-lambda-web-code-123456789012-ap-east-1 
  • Resource: Website bucket Example name:  fsi-trading-desk-portal-123456789012 
  • Resource: DynamoDB table Example name:  FundMetrics 
  • Resource: Cognito user pool Example name:  fsi-trading-desk-users 
  • Resource: Execution role Example name:  FsiMarketMakerWebFunctionRole 
  • Resource: KMS alias Example name:  alias/fsi-market-maker-review 



Step 1: Create a KMS key

  1. Sign in to the AWS Management Console with the approved deployment role.
  1. Select Asia Pacific (Hong Kong)  ap-east-1 .
  1. Open Key Management Service.
  1. Choose Customer managed keys and Create key.
  1. Select Symmetric and Encrypt and decrypt.
  1. Enter alias  alias/fsi-market-maker-review .
  1. Select the designated key administrators.
  1. Select the execution role, deployment role, logging roles, and any approved data-ingestion roles as key users.
  1. Finish creation.
  1. Turn on key rotation if allowed by the key type and company policy.
Use separate KMS keys for production and development if your control framework requires separation of duties.



Step 2: Create the DynamoDB data table

  1. Open DynamoDB.
  1. Choose Tables and Create table.
  1. Enter table name  FundMetrics .
  1. Set the partition key to  fundId  with type String.
  1. Set the sort key to  recordKey  with type String.
  1. Choose On-demand capacity for an unpredictable, small audience. Revisit provisioned capacity when traffic becomes stable.
  1. Under encryption, select the customer-managed KMS key created above.
  1. Enable point-in-time recovery after the table is created.
  1. Enable deletion protection for production.
  1. Add tags such as  Environment=prod ,  DataClassification=confidential ,  Owner=TradingTechnology , and  CostCenter=<value> .

Record layout

Use a key design that supports a complete fund snapshot without an expensive table scan.
  •  fundId :  FUND#ALPHA01   recordKey :  SUMMARY#2026-10-29T08:00:00Z  Example data: NAV, RAUM, calculated timestamp, source timestamps
  •  fundId :  FUND#ALPHA01   recordKey :  HOLDING#2026-10-29#AAPL  Example data: security ID, market value, portfolio weight
  •  fundId :  FUND#ALPHA01   recordKey :  TRADE#2026Q3#000001  Example data: side, quantity, notional, position delta
  •  fundId :  FUND#ALPHA01   recordKey :  PERFORMANCE#2026-10-29  Example data: fund return, benchmark return, beta, alpha, tracking error
Do not use ticker symbols as the authoritative instrument identifier. Use an approved security master identifier and retain ticker only as a display field.

Load synthetic test records through the console

  1. Open the  FundMetrics  table.
  1. Choose Explore table items and Create item.
  1. Switch to JSON view.
  1. Insert a synthetic summary:
{
"fundId": {"S": "FUND#DEMO01"},
"recordKey": {"S": "SUMMARY#LATEST"},
"fundName": {"S": "Synthetic Market Neutral Fund"},
"nav": {"N": "125000000"},
"raum": {"N": "155000000"},
"currency": {"S": "USD"},
"fundReturnYtd": {"N": "0.084"},
"sp500ReturnYtd": {"N": "0.126"},
"alphaYtd": {"N": "-0.042"},
"trackingError": {"N": "0.071"},
"positionsAsOf": {"S": "2026-10-29T08:00:00Z"},
"marketDataAsOf": {"S": "2026-10-29T08:00:00Z"},
"regulatoryDataAsOf": {"S": "2026-09-30"},
"dataQualityStatus": {"S": "SYNTHETIC"}
}
  1. Create additional items for holdings and trades. Never load customer or production trading data into a tutorial environment.



Step 3: Create the Web Function execution role

  1. Open IAM.
  1. Choose Roles and Create role.
  1. Select AWS service as trusted entity.
  1. Select Lambda if the console offers it for this resource. Verify that the trust policy allows  lambda.amazonaws.com  to call  sts:AssumeRole .
  1. Name the role  FsiMarketMakerWebFunctionRole .
  1. Attach only the permissions required by the application.
Create an inline policy called  ReadFundMetricsAndWriteLogs  and replace account, Region, table, key, and log-group values:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadFundMetrics",
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:Query"
],
"Resource": "arn:aws:dynamodb:ap-east-1:123456789012:table/FundMetrics"
},
{
"Sid": "UseApplicationKey",
"Effect": "Allow",
"Action": ["kms:Decrypt", "kms:GenerateDataKey"],
"Resource": "arn:aws:kms:ap-east-1:123456789012:key/REPLACE_WITH_KEY_ID"
},
{
"Sid": "WriteApplicationLogs",
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:ap-east-1:123456789012:log-group:/aws/lambda-web/fsi-market-maker-review-api:*"
}
]
}
If the API needs a vendor credential, add  secretsmanager:GetSecretValue  only for the exact secret ARN. Do not attach  AdministratorAccess ,  PowerUserAccess , or broad DynamoDB permissions.



Step 4: Create the versioned S3 deployment bucket

Lambda Web Functions use S3 ZIP packages. The source bucket must have versioning enabled, and the Lambda service principal must be allowed to read the relevant object and object version.
  1. Open Amazon S3.
  1. Choose Create bucket.
  1. Enter  fsi-lambda-web-code-123456789012-ap-east-1 .
  1. Select Region  ap-east-1 .
  1. Keep Block all public access enabled.
  1. Enable Bucket Versioning.
  1. Select SSE-KMS and the application KMS key.
  1. Create the bucket.
  1. Open Permissions and add a tightly scoped bucket policy after the Web Function name is finalized.
Example policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowLambdaWebFunctionCodeAccess",
"Effect": "Allow",
"Principal": {"Service": "lambda.amazonaws.com"},
"Action": ["s3:GetObject", "s3:GetObjectVersion"],
"Resource": "arn:aws:s3:::fsi-lambda-web-code-123456789012-ap-east-1/releases/*",
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:lambda:ap-east-1:123456789012:web-function/fsi-market-maker-review-api/revision/*"
}
}
}
]
}
Also ensure the KMS key policy allows the Lambda service principal to decrypt the deployment object when SSE-KMS is used. Keep every S3 object version referenced by an active revision. Deleting a pinned object version can permanently move the revision to  Failed ; restoring a different object version does not repair that revision.



Step 5: Create the Express application package

The AWS console can start from a Hello World template, but this use case needs a custom ZIP. Build the following files on an approved workstation or controlled AWS CloudShell environment.

 package.json 

{
"name": "fsi-market-maker-review-api",
"version": "1.0.0",
"private": true,
"main": "index.js",
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.920.0",
"@aws-sdk/lib-dynamodb": "^3.920.0",
"aws-jwt-verify": "^5.1.0",
"express": "^5.1.0",
"helmet": "^8.1.0"
}
}
Pin and scan the exact versions approved by your software-composition-analysis process. The versions above are illustrative and should be validated at deployment time.

 index.js 

const express = require('express');
const helmet = require('helmet');
const crypto = require('crypto');
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
const { DynamoDBDocumentClient, GetCommand, QueryCommand } = require('@aws-sdk/lib-dynamodb');
const { CognitoJwtVerifier } = require('aws-jwt-verify');

const app = express();
app.disable('x-powered-by');
app.use(helmet());
app.use(express.json({ limit: '100kb' }));

const tableName = process.env.TABLE_NAME || 'FundMetrics';
const allowedOrigin = process.env.ALLOWED_ORIGIN;
const region = process.env.AWS_REGION || 'ap-east-1';
const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({ region }));

const verifier = CognitoJwtVerifier.create({
userPoolId: process.env.COGNITO_USER_POOL_ID,
tokenUse: 'access',
clientId: process.env.COGNITO_APP_CLIENT_ID
});

app.use((req, res, next) => {
const requestId = req.get('lambda-web-request-id') || crypto.randomUUID();
res.setHeader('x-request-id', requestId);
res.setHeader('Cache-Control', 'no-store');
if (allowedOrigin) {
res.setHeader('Access-Control-Allow-Origin', allowedOrigin);
res.setHeader('Vary', 'Origin');
res.setHeader('Access-Control-Allow-Headers', 'authorization,content-type,x-request-id');
res.setHeader('Access-Control-Allow-Methods', 'GET,OPTIONS');
}
if (req.method === 'OPTIONS') return res.status(204).end();
next();
});

async function requireTrader(req, res, next) {
try {
const header = req.get('authorization') || '';
if (!header.startsWith('Bearer ')) {
return res.status(401).json({ error: 'missing_bearer_token' });
}
const payload = await verifier.verify(header.slice(7));
const groups = payload['cognito:groups'] || [];
if (!groups.includes('TradingDeskReaders')) {
return res.status(403).json({ error: 'insufficient_group' });
}
req.identity = {
sub: payload.sub,
username: payload.username || payload.client_id,
groups
};
next();
} catch (error) {
console.warn(JSON.stringify({ event: 'auth_failure', message: error.message }));
return res.status(401).json({ error: 'invalid_token' });
}
}

app.get('/api/health', (req, res) => {
res.json({ status: 'ok', region, calculatedAt: new Date().toISOString() });
});

app.get('/api/v1/funds/:fundId/overview', requireTrader, async (req, res) => {
try {
const fundId = String(req.params.fundId || '');
if (!/^DEMO[0-9]{2}$/.test(fundId)) {
return res.status(400).json({ error: 'invalid_fund_id' });
}

const result = await ddb.send(new GetCommand({
TableName: tableName,
Key: {
fundId: `FUND#${fundId}`,
recordKey: 'SUMMARY#LATEST'
},
ConsistentRead: true
}));

if (!result.Item) return res.status(404).json({ error: 'fund_not_found' });

const item = result.Item;
const response = {
fundId,
fundName: item.fundName,
currency: item.currency,
managementMetrics: {
topHoldingsEndpoint: `/api/v1/funds/${fundId}/holdings`,
largestTradesEndpoint: `/api/v1/funds/${fundId}/trades`,
portfolioStructureEndpoint: `/api/v1/funds/${fundId}/structure`
},
performance: {
nav: item.nav,
regulatoryAum: item.raum,
fundReturnYtd: item.fundReturnYtd,
sp500ReturnYtd: item.sp500ReturnYtd,
alphaYtd: item.alphaYtd,
trackingError: item.trackingError
},
provenance: {
positionsAsOf: item.positionsAsOf,
marketDataAsOf: item.marketDataAsOf,
regulatoryDataAsOf: item.regulatoryDataAsOf,
dataQualityStatus: item.dataQualityStatus,
calculatedAt: new Date().toISOString()
}
};

console.info(JSON.stringify({
event: 'fund_overview_read',
fundId,
principal: req.identity.sub,
requestId: res.getHeader('x-request-id')
}));

return res.json(response);
} catch (error) {
console.error(JSON.stringify({ event: 'api_error', message: error.message }));
return res.status(500).json({ error: 'internal_error' });
}
});

app.get('/api/v1/funds/:fundId/holdings', requireTrader, async (req, res) => {
const fundId = String(req.params.fundId || '');
if (!/^DEMO[0-9]{2}$/.test(fundId)) return res.status(400).json({ error: 'invalid_fund_id' });
const result = await ddb.send(new QueryCommand({
TableName: tableName,
KeyConditionExpression: 'fundId = :fundId AND begins_with(recordKey, :prefix)',
ExpressionAttributeValues: {
':fundId': `FUND#${fundId}`,
':prefix': 'HOLDING#'
},
Limit: 25,
ScanIndexForward: false
}));
res.json({ fundId, items: result.Items || [], calculatedAt: new Date().toISOString() });
});

app.use((req, res) => res.status(404).json({ error: 'not_found' }));

const [host, port] = (process.env.AWS_LAMBDA_HTTP_ENDPOINT || 'localhost:3000').split(':');
app.listen(Number(port), host, () => {
console.info(JSON.stringify({ event: 'server_started', host, port: Number(port) }));
});
AWS requires the server to listen on the host and port supplied in  AWS_LAMBDA_HTTP_ENDPOINT . The default entry file is  index.js  at the ZIP root. AWS provides an Express example in  Web Function sample applications .

Build the ZIP

Run in the directory containing  package.json  and  index.js :
npm install
npm audit
npm prune --omit=dev
zip -r fsi-market-maker-review-api-1.0.0.zip index.js package.json package-lock.json node_modules
The ZIP must contain  index.js  at its root, not inside a parent folder.

Upload through the S3 console

  1. Open the code bucket.
  1. Create folder  releases/1.0.0/ .
  1. Upload  fsi-market-maker-review-api-1.0.0.zip .
  1. Copy the object key.
  1. Open Versions and record the exact Version ID for the release evidence.



Step 6: Create the Lambda Web Function through the console

  1. Open the Lambda console:  https://console.aws.amazon.com/lambda/ .
  1. Confirm Region  ap-east-1 .
  1. In the left navigation, choose Web Functions. Do not choose Event Functions for this walkthrough.
  1. Choose Create Web Function.
  1. Under Basic information:
  • Function name:  fsi-market-maker-review-api 
  • Runtime: keep the supported default Node.js runtime, expected to be Node.js 24 for the current workflow.
  • Code source: choose Amazon S3 or Upload ZIP file. For controlled production deployment, select the versioned S3 object.
  • Select bucket  fsi-lambda-web-code-123456789012-ap-east-1 .
  • Enter object key  releases/1.0.0/fsi-market-maker-review-api-1.0.0.zip .
  • If prompted, select or enter the exact object Version ID.
  1. Under Endpoint configuration:
  • Endpoint name:  prod-hk 
  • Type:  Home-Region 
  • Authentication type:  Application-managed authentication  for the Cognito JWT pattern in this guide.
  • Auto deployment: choose Disabled for production if you require manual revision promotion. For a development endpoint, Latest revision is convenient.
  1. Expand Additional configurations:
  • Select existing execution role  FsiMarketMakerWebFunctionRole .
  • Select the approved S3 code bucket where applicable.
  • Select the KMS key.
  • Add tags.
  • Set environment variables listed below.
  1. Choose Create Web Function.
  1. Wait for both the revision and endpoint to become Active.
  1. Open the Endpoints tab, select  prod-hk , and copy the endpoint domain.
  1. Test  /api/health  in a browser or with  curl .
The console creates a Web Function, an immutable first revision, and an endpoint. A revision can show Active even if the application failed to start listening, so always make an HTTP request and inspect logs after deployment. See  Creating a Lambda Web Function .

Environment variables

  • Name:  TABLE_NAME  Example value:  FundMetrics 
  • Name:  COGNITO_USER_POOL_ID  Example value: added after Step 7
  • Name:  COGNITO_APP_CLIENT_ID  Example value: added after Step 7
  • Name:  ALLOWED_ORIGIN  Example value: final CloudFront URL or custom portal domain
  • Name:  LOG_LEVEL  Example value:  INFO 
Do not put API secrets in this list.

Initial health test

curl -i https://REPLACE_WITH_ENDPOINT_DOMAIN/api/health
Expected response:
{
"status": "ok",
"region": "ap-east-1",
"calculatedAt": "2026-10-29T08:30:00.000Z"
}



Series: Financial Service (33 articles)

  1. …
  2. 26
    AWS Lambda Web Functions Through the AWS Console - Part 1 This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article