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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair google pub/sub and kong to turn live web traffic into fast background events. Kong takes incoming client calls and sends event payloads right into Google Pub/Sub topics. This workflow keeps public web APIs fast while backend workers process jobs at their own pace. Clients get a fast reply from the edge, and backend apps read messages when ready. How google pub/sub and kong move data and check keys Data starts when a client app sends a web request to a Kong route. Kong checks the c

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 google pub/sub and kong to turn live web traffic into fast background events. Kong takes incoming client calls and sends event payloads right into Google Pub/Sub topics.

This workflow keeps public web APIs fast while backend workers process jobs at their own pace. Clients get a fast reply from the edge, and backend apps read messages when ready.

How google pub/sub and kong move data and check keys

Data starts when a client app sends a web request to a Kong route. Kong checks the client key or token before it lets the request pass through.

Next, Kong changes the web request into a format that Google Pub/Sub can read. It wraps the payload and sends it to the Google Cloud API endpoint over HTTPS.

Google Pub/Sub needs a valid cloud identity before it accepts any new message from Kong. Teams link a Google service account to Kong so it can write to one topic.

Once the cloud topic gets the message, it sends a success code back to Kong. Kong then tells the client app that the job is in the queue for work.

Downstream worker apps subscribe to that topic and pull messages to run background tasks. This split keeps slow database writes or billing tasks off the main web path.

Common failure modes and how to scope roles

Many teams make the mistake of using one shared service account for all Kong routes. If one route leaks its key, an attacker can write to every topic you own.

Static service account keys stored on Kong nodes also create a big security risk. Engineers copy these static keys onto local disks, and they rarely rotate them on time.

End-to-End Encryption + Kong Security Plugins: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad cloud roles cause trouble too when a route gets read and admin rights. A route that only sends events should never have the power to delete a topic.

To fix this, give each Kong service a narrow role for one single topic. Use workload identity federation where you can so you do not store static keys.

Unlogged payloads are another big blind spot for security and ops teams in production. If Kong sends raw user data to a topic, sensitive fields can spread to many apps.

Data masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results. You should also log every publish call with the caller identity and the target topic name.

Keeping network paths and message schemas clean

Network paths between your edge nodes and Google Cloud need tight egress rules in production. Lock down outbound traffic so nodes only talk to known Google API IP ranges.

Set clear timeout and retry rules on your Kong routes to handle brief cloud drops. If a retry rule is too aggressive, it can flood a topic with duplicate events.

Make sure every worker app checks message IDs so it can skip duplicate jobs safely. You can also attach a schema to your topic to block bad JSON payloads early.

When Kong sends a broken payload, the topic rejects it before any worker crashes. This simple check keeps bad data out of your backend queues and saves hours of debugging.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can Kong send messages to Google Pub/Sub without custom backend code?

Yes, Kong can transform incoming HTTP requests and post them directly to the Google REST API. This setup lets you publish events from the edge without running a middle app.

What role should Kong use to write to a Google Pub/Sub topic?

Grant the service account only the Publisher role on the single topic it needs. Never grant project-wide editor rights or subscriber permissions to an edge route that only sends data.

How do we stop duplicate messages when Kong retries a failed request?

Have the client send a unique request ID header and pass it as a message attribute. Downstream workers can check this ID to drop duplicate events before they run a task.

The query runs. The emails stay hidden.