The Simplest Way to Make Akamai Edgeworkers and Google Pub/Sub Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair akamai edgeworkers and google pub/sub to stream user events from the edge. Edge scripts process HTTP requests near users and send messages to cloud topics. This setup moves heavy work away from your core backend apps. Edge scripts capture clicks, logs, or telemetry and forward them for processing. Downstream services then read those messages at their own pace. Your origin servers stay fast even during large traffic spikes. How akamai edgeworkers and google pub/sub pass data and key

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams pair akamai edgeworkers and google pub/sub to stream user events from the edge. Edge scripts process HTTP requests near users and send messages to cloud topics.

This setup moves heavy work away from your core backend apps. Edge scripts capture clicks, logs, or telemetry and forward them for processing. Downstream services then read those messages at their own pace. Your origin servers stay fast even during large traffic spikes.

How akamai edgeworkers and google pub/sub pass data and keys

An edge script runs when a user hits an Akamai edge server. The script reads the request headers and builds a small JSON payload. Next, it makes an outbound HTTPS call to the Google Cloud endpoint. The message lands in a specific topic for backend workers to read.

Every outbound call from the edge needs a valid cloud token. Google Cloud uses service accounts and roles to check who sends data. Edge scripts have strict limits on run time and memory usage. Running a full OAuth flow on every single edge request adds high latency.

To fix this, teams store cached tokens inside Akamai edge key-value storage. A separate background job refreshes the token before it expires. The edge script reads the fresh token from local storage in milliseconds. It attaches the token to the request header and sends the event.

You must also watch outbound subrequest limits at the edge. Each edge trigger can only make a few external network calls. Batching data or sending only critical events keeps your scripts within limits. Keep payloads small so the network call finishes before the timeout hits.

Common failure modes and how to scope roles

Many teams fail by using one broad service account for all edge scripts. If a key leaks, an attacker can read or delete cloud topics. Always assign a narrow publisher role to the edge service account. That role should only allow writing messages to one specific topic.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Another common issue is hardcoding static keys inside the edge script bundle. When it is time to rotate keys, you must deploy code again. Edge code deployments take time to spread across the global network. Store secrets in dedicated edge storage so you can rotate them fast.

Unlogged errors at the edge also cause silent data loss in production. If a cloud endpoint returns an error, the edge script drops the message. Set up failure logs to capture status codes from rejected calls. Alert your team when error rates rise so they can fix bad keys.

Finally, raw user requests often carry personal data like emails or phone numbers. Sending raw payloads straight to a message bus spreads sensitive fields across apps. Strip or mask emails, card numbers, and phone numbers before sending the message. This keeps sensitive data out of downstream logs and analytics tables.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Why do edge calls to Google Pub/Sub time out?

Edge scripts have tight wall-clock limits for outbound network calls. Timeouts happen when the script builds a new token on every request. Cache your access token at the edge and use a nearby cloud region.

What role should the Google Cloud service account have?

Give the service account only the Pub/Sub Publisher role on one topic. Never grant project-wide editor roles or read permissions to edge workers. This limits damage if an edge token ever leaks.

How should we handle personal data in edge events?

Filter or rewrite sensitive fields inside the edge script before sending the payload. Remove or mask emails, phone numbers, and national IDs at the edge. This stops raw personal data from landing in your cloud message topics.

The query runs. The emails stay hidden.