Under the hood
A detailed look at how CloudLens works โ from the Chrome extension manifest to the AWS SigV4 signing implementation, the Lambda proxy, and the security model that keeps your credentials safe.
High-level architecture
CloudLens is a Manifest V3 Chrome extension with three main components: a content script injected into AWS Console pages, a background service worker that handles all API calls, and a popup UI for settings and account summary. All three communicate via Chrome's message passing API.
The extension makes two types of external calls โ directly to the AWS Cost Explorer API (SigV4-signed, using your IAM credentials) and to a Lambda proxy that forwards AI summary requests to the Anthropic Claude API. Your credentials and cost data never reach CloudLens servers.
Declares permissions, host_permissions, content script rules, service worker, and popup action. Manifest V3 required for all new Chrome Web Store listings.
Message router. Handles GET_ACCOUNT_SUMMARY, GET_AI_SUMMARY, CREDENTIALS_SAVED, and the weekly Monday digest alarm.
Cost Explorer API client with hand-rolled SigV4 signing using the Web Crypto API. No AWS SDK โ keeps the bundle under 50KB.
Sends anonymised cost data to the Lambda proxy. Returns plain-English AI summaries for the badge tooltip.
Content script. Watches for AWS Console URL changes every 600ms, parses resource type from URL pattern, injects cost badge into the page DOM.
TTL cache using chrome.storage.session. Cost data cached 4 hours, AI summaries 24 hours. Avoids hammering the Cost Explorer API on every page load.
MV3 replaces persistent background pages with service workers โ ephemeral processes that spin down when idle and wake on demand. This has three important implications:
chrome.storage โ never in-memory variables that reset when the worker terminates.chrome.alarms rather than setInterval, which wouldn't survive worker termination.host_permissions for every domain the extension communicates with. CloudLens declares only the AWS Console, Cost Explorer API, and the Lambda proxy endpoint.The Cost Explorer API requires every request to be signed using AWS Signature Version 4. Rather than bundling the AWS SDK (which adds ~3MB), CloudLens implements SigV4 signing using the browser's native Web Crypto API, available in service workers.
AWS4+secret โ date โ region โ service โ aws4_request. Each step adds specificity to the key.Authorization header on every request.CloudLens requires a dedicated IAM user with this minimal read-only policy. It cannot access any service data โ only billing records.
Chrome extensions cannot call the Anthropic API directly due to CORS restrictions. CloudLens routes AI summary requests through a Lambda function deployed via CloudFormation.
api.anthropic.com/v1/messageschrome.storage.local (encrypted at rest). Transmitted only to ce.us-east-1.amazonaws.com. Never sent to CloudLens servers.chrome.storage.session (cleared on browser close). Never sent to CloudLens servers.chrome.storage.local. Transmitted to the Lambda proxy only, which forwards it to Anthropic without logging it.The content script watches for URL changes every 600ms and maps them to resource types:
/ec2/ โ EC2 instances, EBS volumes, load balancers/s3/ โ S3 buckets/rds/ โ RDS databases and Aurora clusters/lambda/ โ Lambda functions/dynamodb/ โ DynamoDB tables/ecs/ โ ECS clusters and services/cloudfront/ โ CloudFront distributions/cost-management/ โ Account billing total