The Simplest Way to Make Cloud Functions and Kong Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running cloud functions and kong together lets you route web traffic to serverless code. Kong checks incoming requests first, and then your cloud functions run the backend task. Teams use this pair to build fast web apps without managing full servers. Kong acts as the front door for all your external user traffic. It blocks bad requests, checks user keys, and applies rate limits right away. Meanwhile, the serverless functions scale up and down based on real demand. You only pay for the exact co

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.

Running cloud functions and kong together lets you route web traffic to serverless code. Kong checks incoming requests first, and then your cloud functions run the backend task.

Teams use this pair to build fast web apps without managing full servers. Kong acts as the front door for all your external user traffic. It blocks bad requests, checks user keys, and applies rate limits right away. Meanwhile, the serverless functions scale up and down based on real demand. You only pay for the exact compute time your functions use.

How requests and permissions flow between cloud functions and kong

When a user sends a request, Kong receives it at the network edge. Kong checks the route rules to see where the request should go. Next, it verifies the user identity using a key or a token. If the user lacks a valid token, Kong drops the request right there. Your backend code does not even wake up or waste compute money.

Once Kong approves the user, it needs permission to trigger the cloud function. Public functions are dangerous because anyone on the web can call them directly. Instead, teams lock down the function so only trusted identities can invoke it. Kong holds a cloud role or service key with permission to trigger that function. It attaches a signed token to the request and sends it over HTTPS. The cloud platform checks this token, runs the function, and returns the response.

Common failure modes and how to scope roles

Many teams make mistakes when they set up these two tools at scale. The biggest issue is using one shared service account for every single route. If Kong uses one giant key, any route can trigger any backend function. A tiny mistake in a route rule could expose billing or admin functions. Another common trap is leaving the cloud function open to the public internet. Attackers can bypass Kong and hit the function URL to run up bills.

To fix this, give each route or service group its own specific role. Scope each role so it can only invoke the exact function it needs. Keep your keys short-lived so stolen credentials expire before attackers can use them. You should also restrict network paths using private cloud networks or ingress rules. Make sure your cloud functions reject any traffic that does not come from Kong. Finally, turn on detailed request logs in both systems to track every call. Good logs show who called the endpoint, which route ran, and what happened.

Cloud Functions IAM + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Keeping data safe during serverless execution

Even with good network rules, functions often handle sensitive customer data in responses. Payloads might hold personal details like emails, phone numbers, card numbers, or national IDs. If an error occurs, raw logs might capture these fields in plain text. Developers checking those logs for bugs will see private user data by accident.

Teams should filter and clean payloads before logs or responses leave the system. Data masking rewrites matched fields in results so raw values stay protected. It replaces real card numbers or emails with safe placeholders during transit. This simple step keeps test environments and central log tools much safer.

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

Why put Kong in front of serverless cloud functions?

Kong handles rate limits, user logins, and request logs in one central place. This keeps your function code small, fast, and focused on core business logic.

How do I stop users from calling my cloud function URL directly?

Turn off public access on the function and require a valid cloud role. Also set network ingress rules so the function only accepts traffic from Kong.

Should all Kong routes share one cloud service account?

No, sharing one account gives every route too much power across your cloud. Create separate roles for different route groups to limit the blast radius.

The query runs. The emails stay hidden.