Under the hood

Architecture

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

Chrome browser User's machine ยท no data leaves this box Content script injector.js Service worker service-worker.js Popup UI popup.js chrome.storage encrypted ยท local only AWS Console DOM ยท URL detection messages Cost Explorer API ce.us-east-1.amazonaws.com Lambda proxy API Gateway ยท us-east-1 Claude API api.anthropic.com CloudFront + S3 getcloudlens.com SigV4 signed AI summary request landing page Extension components AWS services Anthropic API Internal browser

Overview

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.

manifest.json

Declares permissions, host_permissions, content script rules, service worker, and popup action. Manifest V3 required for all new Chrome Web Store listings.

service-worker.js

Message router. Handles GET_ACCOUNT_SUMMARY, GET_AI_SUMMARY, CREDENTIALS_SAVED, and the weekly Monday digest alarm.

aws-client.js

Cost Explorer API client with hand-rolled SigV4 signing using the Web Crypto API. No AWS SDK โ€” keeps the bundle under 50KB.

claude-client.js

Sends anonymised cost data to the Lambda proxy. Returns plain-English AI summaries for the badge tooltip.

injector.js

Content script. Watches for AWS Console URL changes every 600ms, parses resource type from URL pattern, injects cost badge into the page DOM.

cache.js

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.

Manifest V3 โ€” key design decisions

MV3 replaces persistent background pages with service workers โ€” ephemeral processes that spin down when idle and wake on demand. This has three important implications:

AWS SigV4 signing โ€” no SDK

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.

01
Canonical request
Sort and lowercase headers, SHA-256 hash the request body, build a canonical string from method, path, headers, and body hash.
02
String to sign
Combine algorithm identifier, timestamp, credential scope (date/region/service), and the hash of the canonical request.
03
Signing key derivation
HMAC chain using the secret key: AWS4+secret โ†’ date โ†’ region โ†’ service โ†’ aws4_request. Each step adds specificity to the key.
04
Final signature
HMAC-SHA256 of the string-to-sign with the derived key, hex-encoded. Added to the Authorization header on every request.

IAM policy

CloudLens requires a dedicated IAM user with this minimal read-only policy. It cannot access any service data โ€” only billing records.

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "ce:GetCostAndUsage",
      "ce:GetCostAndUsageWithResources",
      "ce:GetDimensionValues",
      "ce:GetCostForecast"
    ],
    "Resource": "*"
  }]
}

Lambda proxy for Claude API

Chrome extensions cannot call the Anthropic API directly due to CORS restrictions. CloudLens routes AI summary requests through a Lambda function deployed via CloudFormation.

Data flow and privacy

Supported AWS Console URL patterns

The content script watches for URL changes every 600ms and maps them to resource types: