AWS Builder Center

AWS Lambda Web Functions for Private Equity and Venture Capital Fund Analytics - Part 2

AWS Lambda Web Functions for Private Equity and Venture Capital Fund Analytics - Part 2

Series: Financial Service (33 articles)

  1. …
  2. 23
    AWS Lambda Web Functions for Private Equity and Venture Capital Fund Analytics - Part 2 This article
Dev @ Vertex Macro

Step 6: Create the scheduled Event Function

The daily job should be a separate Event Function. It can retrieve external data, normalize it, calculate portfolio metrics, and write an atomic publication set to S3.

Example worker structure

// index.mjs
import { randomUUID } from 'node:crypto';
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';

const s3 = new S3Client({});
const secrets = new SecretsManagerClient({});

export const handler = async (event) => {
const runId = event.runId || randomUUID();
const asOfDate = event.asOfDate || new Date().toISOString().slice(0, 10);
const bucket = process.env.ANALYTICS_BUCKET;

const secretResult = await secrets.send(new GetSecretValueCommand({
SecretId: process.env.PROVIDER_SECRET_ARN
}));
const provider = JSON.parse(secretResult.SecretString);

// Apply provider timeout, retry with jitter, response-size limits,
// schema validation, and license-approved endpoints.
const response = await fetch(`${provider.baseUrl}/fund-data?asOf=${asOfDate}`, {
headers: { Authorization: `Bearer ${provider.apiKey}` },
signal: AbortSignal.timeout(20000)
});
if (!response.ok) throw new Error(`Provider returned HTTP ${response.status}`);

const raw = await response.json();
validateProviderSchema(raw);
const metrics = calculateFundMetrics(raw, asOfDate);

await putJson(bucket,
`raw/provider=market-data/as_of=${asOfDate}/run_id=${runId}.json`,
raw,
runId
);

await putJson(bucket,
`metrics/fund_id=${metrics.fundId}/as_of=${asOfDate}/summary.json`,
metrics,
runId
);

const manifest = {
runId,
asOfDate,
status: 'SUCCEEDED',
calculationVersion: process.env.CALCULATION_VERSION,
sourceRetrievedAt: new Date().toISOString(),
outputKey: `metrics/fund_id=${metrics.fundId}/as_of=${asOfDate}/summary.json`
};

await putJson(bucket,
`manifests/run_date=${asOfDate}/run_id=${runId}.json`,
manifest,
runId
);

return manifest;
};

async function putJson(bucket, key, value, runId) {
await s3.send(new PutObjectCommand({
Bucket: bucket,
Key: key,
Body: JSON.stringify(value),
ContentType: 'application/json',
ServerSideEncryption: 'aws:kms',
SSEKMSKeyId: process.env.KMS_KEY_ARN,
Metadata: { run_id: runId }
}));
}

function validateProviderSchema(raw) {
if (!raw || typeof raw !== 'object') throw new Error('Invalid provider payload');
}

function calculateFundMetrics(raw, asOfDate) {
// Replace with independently tested, version-controlled calculations.
return { fundId: raw.fundId, asOfDate, status: 'calculated' };
}

Create the Event Function in the console

  1. Open AWS Lambda.
  1. Choose Event Functions and then Create function.
  1. Choose Author from scratch.
  1. Function name:  pe-vc-fund-daily-refresh-prod .
  1. Runtime: select the approved Node.js runtime.
  1. Architecture: choose  arm64  only after confirming all native dependencies support it; otherwise use  x86_64 .
  1. Under permissions, create a new role with basic Lambda permissions, or select a pre-created least-privilege role.
  1. Create the function.
  1. Upload the worker ZIP under the Code tab.
  1. Set handler to match the module, for example  index.handler  if required by the selected packaging format.
  1. Under Configuration > General configuration, set:
  • Memory: begin at 1,024 to 2,048 MB for calculation-heavy Node.js work, then benchmark.
  • Timeout: choose a value below 15 minutes, allowing time for cleanup and a controlled failure.
  • Ephemeral storage: increase  /tmp  only when processing files that do not fit comfortably in memory. Lambda supports configurable ephemeral storage; do not treat  /tmp  as durable storage.
  1. Under Environment variables, add:
ANALYTICS_BUCKET=pe-vc-fund-analytics-prod-<account-id>-ap-east-1
PROVIDER_SECRET_ARN=<secret-arn>
KMS_KEY_ARN=<kms-key-arn>
CALCULATION_VERSION=2026.10.1

Worker IAM policy

Attach a policy narrowed to the exact bucket prefixes, secret, and KMS key:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "WriteFundAnalytics",
"Effect": "Allow",
"Action": ["s3:PutObject", "s3:AbortMultipartUpload"],
"Resource": [
"arn:aws:s3:::pe-vc-fund-analytics-prod-<account-id>-ap-east-1/raw/*",
"arn:aws:s3:::pe-vc-fund-analytics-prod-<account-id>-ap-east-1/curated/*",
"arn:aws:s3:::pe-vc-fund-analytics-prod-<account-id>-ap-east-1/metrics/*",
"arn:aws:s3:::pe-vc-fund-analytics-prod-<account-id>-ap-east-1/manifests/*"
]
},
{
"Sid": "ReadProviderSecret",
"Effect": "Allow",
"Action": ["secretsmanager:GetSecretValue"],
"Resource": "<secret-arn>"
},
{
"Sid": "UseAnalyticsKey",
"Effect": "Allow",
"Action": ["kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKey"],
"Resource": "<kms-key-arn>"
}
]
}
Do not grant the worker permission to delete historical source or metric objects unless a separately controlled retention process requires it.



Step 7: Create the dead-letter queue

  1. Open Amazon SQS.
  1. Choose Create queue.
  1. Type: Standard.
  1. Name:  pe-vc-fund-daily-refresh-dlq-prod .
  1. Use SSE-KMS if required.
  1. Set message retention according to incident-response needs, for example 14 days.
  1. Create the queue.
  1. Add a queue policy allowing the EventBridge Scheduler execution role to send failed invocations to this queue.
A DLQ records failed delivery after Scheduler exhausts its retry policy. It does not replace application-level error logging or a manifest indicating that a business calculation failed.



Step 8: Schedule the daily job with EventBridge Scheduler

AWS recommends EventBridge Scheduler over legacy EventBridge scheduled rules because Scheduler provides centralized schedules, flexible windows, retries, retention controls, and dead-letter queue support.
  1. Open Amazon EventBridge.
  1. In the navigation pane, choose Scheduler and then Schedules.
  1. Choose Create schedule.
  1. Schedule name:  pe-vc-fund-refresh-daily-prod .
  1. Schedule group: use  default  or create a controlled application-specific group.
  1. Choose Recurring schedule.
  1. Select Cron-based schedule.
  1. Example cron expression:
cron(15 6 ? * MON-FRI *)
  1. Set timezone to Asia/Hong_Kong if the console supports schedule timezones for the selected workflow.
  1. Flexible time window:
  • Choose Off when business operations require a precise launch time.
  • Use a bounded window when provider load spreading is acceptable.
  1. Choose target type AWS Lambda Invoke.
  1. Select  pe-vc-fund-daily-refresh-prod .
  1. Enter a small static payload:
{
"trigger": "daily-schedule",
"requestedDataset": "fund-performance"
}
Do not hard-code  asOfDate  in a recurring schedule. The worker should determine the correct business date using an approved trading calendar and vendor publication status.
  1. Under Retry policy and dead-letter queue:
  • Choose a maximum event age that matches the data's usefulness.
  • Configure several retries with enough time for transient provider outages.
  • Select  pe-vc-fund-daily-refresh-dlq-prod .
  1. Let the console create a Scheduler execution role, or select a dedicated role permitted only to invoke this Event Function and send failed messages to the DLQ.
  1. Enable the schedule and create it.

Scheduling cautions

  • A Monday-to-Friday cron expression does not understand US, Hong Kong, or fund-specific holidays.
  • External providers may publish corrected data after the first file. Add a controlled reprocessing path with a new  runId , not an overwrite without lineage.
  • If work can exceed Lambda's maximum invocation duration, split by fund or date using SQS or orchestrate the workflow with AWS Step Functions. Do not increase the HTTP timeout and hope the request completes.



Step 9: Test end to end

Test the worker manually

  1. Open the Event Function.
  1. Choose Test.
  1. Create an event named  manual-fund-refresh-test :
{
"trigger": "console-test",
"asOfDate": "2026-10-28",
"runId": "console-test-20261028"
}
  1. Invoke the function.
  1. Confirm:
  • Invocation succeeded.
  • No secret value appears in logs.
  • Raw, metrics, and manifest objects exist under the expected S3 keys.
  • Objects use the approved KMS key.
  • Manifest source time, calculation version, and output references are correct.
  • Re-running the same test does not silently corrupt or duplicate financial results.

Test the Web Function

  1. Open the Web Function endpoint.
  1. Call  /health  through the approved authenticated route.
  1. Call  /api/funds/FUND-001/metrics/latest .
  1. Verify server-side authorization, not only UI hiding.
  1. Confirm the response includes an  asOfDate , calculation version, source freshness indicator, and clear stale-data warning when the latest run failed.

Negative tests

  • Invalid fund identifier.
  • Unauthorized user and user assigned to another fund.
  • S3 object missing.
  • KMS access denied.
  • Provider returns 429, 500, malformed JSON, an unexpected schema version, or an oversized payload.
  • Calculation does not reconcile TVPI to DPI + RVPI within the documented tolerance.
  • EventBridge retries create duplicate invocations.
  • Data is corrected after publication.



Step 10: Monitoring and alerting

CloudWatch Logs

Use structured JSON logs containing:
  •  runId 
  •  fundId  or a non-sensitive surrogate identifier
  •  asOfDate 
  •  calculationVersion 
  • provider name
  • source retrieval timestamp
  • duration
  • input/output record counts
  • validation status
  • error category
Never log credentials, complete holdings payloads, investor PII, raw authorization headers, or confidential side-letter terms.

CloudWatch alarms

Create alarms for:
  • Event Function  Errors > 0  over the daily run period.
  •  Throttles > 0 .
  • Duration approaching the configured timeout.
  • DLQ  ApproximateNumberOfMessagesVisible > 0 .
  • Missing expected success manifest by a business deadline.
  • Web Function elevated 5xx rate or latency.
  • KMS access-denied events and unexpected S3 access patterns through CloudTrail or your SIEM.
A successful Lambda invocation does not prove correct financial output. Add business-control alarms for stale data, reconciliation breaks, missing funds, implausible NAV movement, benchmark gaps, and source-date regressions.



Financial-services control checklist

Data governance

  • Classify holdings, valuations, investor information, and regulatory filings.
  • Verify vendor licenses permit storage, transformation, and display.
  • Maintain a data dictionary and lineage from source to every published ratio.
  • Record valuation source, stale-price policy, FX source, and cutoff timestamp.
  • Separate SEC public filing data from confidential internal AUM and NAV measures.

Calculation governance

  • Version every formula and dependency.
  • Independently test TVPI, DPI, RVPI, IRR, PME, concentration, and exposure calculations.
  • Use golden datasets with expected results.
  • Require change approval for calculation logic.
  • Preserve source and result artifacts for reproducibility.
  • Do not compare private-fund IRR directly with an S&P 500 price-return percentage without a documented PME methodology.

Security

  • Enforce SSO/MFA for administrators and fund users.
  • Apply least-privilege IAM and separate web-read from worker-write roles.
  • Encrypt with SSE-KMS and restrict key policies.
  • Keep S3 Block Public Access enabled.
  • Use Secrets Manager for provider credentials.
  • Define dependency patching, SBOM, vulnerability scanning, and artifact-signing controls.
  • Use VPC networking only when required for private resources or controlled egress; remember that a VPC-attached Lambda needs an approved path for external API access.

Operations

  • Define recovery time and recovery point objectives.
  • Document replay, backfill, vendor outage, and late-correction procedures.
  • Make scheduled processing idempotent using  runId , source date, conditional writes, or a run-lock mechanism.
  • Use Step Functions or SQS fan-out when the job becomes too large for one Lambda invocation.
  • Test restore and cross-Region recovery rather than assuming S3 versioning alone is a complete backup strategy.

Regulatory and records considerations

Coordinate the design with legal and compliance teams for applicable obligations, which may include SEC books-and-records requirements, Form ADV controls, privacy requirements, cybersecurity policies, vendor-risk management, and local rules affecting Hong Kong operations. This guide is an engineering pattern, not a legal determination.



Cost and operating model

The design removes the fixed cost and patching duty of an always-on EC2 web host. Cost becomes usage-based across:
  • Lambda Web Function active compute and memory.
  • Lambda Event Function requests, duration, memory, and ephemeral storage where configured.
  • EventBridge Scheduler invocations.
  • S3 storage, requests, lifecycle transitions, replication, and retrieval.
  • KMS API calls.
  • Secrets Manager secret storage and API calls.
  • CloudWatch log ingestion, retention, metrics, and alarms.
  • Network egress, NAT Gateway, or other controlled-egress components if used.
Do not assume serverless is automatically cheaper. A high-volume, CPU-saturated, always-busy service may favor a different compute model. For this workload, Web Functions are most compelling when trader/API traffic is intermittent and the daily calculation is bounded and scheduled.



Recommended implementation sequence

  1. Build the S3, KMS, and Secrets Manager foundation in a development account.
  1. Create the daily Event Function and validate one non-sensitive sample fund.
  1. Add calculation reconciliation and immutable run manifests.
  1. Create EventBridge Scheduler, retries, and DLQ.
  1. Deploy the existing Express/Fastify application as a Lambda Web Function with read-only access.
  1. Add enterprise authentication and fund-level authorization.
  1. Run security, load, failure, and financial-calculation tests.
  1. Promote a new immutable Web Function revision and production worker artifact through the approved change process.
  1. Retire the EC2 cron job only after parallel runs produce reconciled results for an agreed observation period.
  1. Decommission EC2 after rollback requirements, evidence retention, and cost review are complete.



Official references

  •  AWS Lambda Web Adapter  for migration scenarios that still use Event Functions, API Gateway, Function URLs, or container images



Final design summary

Use Lambda Web Functions for the existing Fastify or Express fund analytics HTTP application, and use a separate Lambda Event Function triggered by Amazon EventBridge Scheduler for daily external-data ingestion and fund-performance calculations. Publish versioned raw data, curated datasets, metrics, and run manifests to an SSE-KMS encrypted S3 bucket. This removes the always-on EC2 server and operating-system cron job while improving workload isolation, auditability, reproducibility, and least-privilege access.

Series: Financial Service (33 articles)

  1. …
  2. 23
    AWS Lambda Web Functions for Private Equity and Venture Capital Fund Analytics - Part 2 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