The Simplest Way to Make Cloud Run and Sagemaker Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use cloud run and sagemaker together to serve stateless web apps backed by hosted machine learning models. In this setup, Google Cloud handles user traffic while AWS runs model inference. Linking these two platforms lets developers keep web apps on Google Cloud while ML teams stay on AWS. You do not need to move training data or rebuild your existing pipelines. You only need a safe path for requests to cross between the two clouds. How identity and data flow between cloud run and sagema

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 use cloud run and sagemaker together to serve stateless web apps backed by hosted machine learning models. In this setup, Google Cloud handles user traffic while AWS runs model inference.

Linking these two platforms lets developers keep web apps on Google Cloud while ML teams stay on AWS. You do not need to move training data or rebuild your existing pipelines. You only need a safe path for requests to cross between the two clouds.

How identity and data flow between cloud run and sagemaker

A request starts when a user hits your web service on Google Cloud. The container processes the input and prepares a payload for the model endpoint on AWS. Before the container can send that payload, it must prove its identity to AWS.

Each Google Cloud service runs with its own local service account. AWS cannot read Google permissions on its own, so you must set up workload identity federation. The container fetches an identity token from Google and trades it for temporary AWS credentials.

Once the container holds valid AWS credentials, it signs the request and sends it over HTTPS. The AWS endpoint checks the signature, runs the model, and returns the prediction to the container. The web app formats the result and sends the final response back to the user.

Common failure modes in cross-cloud model calls

The biggest mistake teams make is putting static AWS keys inside container variables. Long-lived keys can leak in build logs, source code, or crash dumps. If an attacker finds a static key, they can call your models from anywhere.

Overly broad IAM roles create another major risk for engineering teams. A web app only needs permission to invoke one specific model endpoint on AWS. Giving the role permission to list endpoints, read storage buckets, or change settings invites lateral movement.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared service accounts also break audit trails across both cloud providers. When five different apps share one identity, your logs cannot show which app made a bad call. Give every single web service its own dedicated identity and its own scoped AWS role.

Unlogged payloads cause problems when sensitive user data crosses cloud boundaries. User inputs often include emails, phone numbers, card numbers, or national IDs. Data masking rewrites matched fields in results and payloads before they hit external logs or model endpoints.

Scoping network paths and permissions

Start by locking down the trust policy on your AWS IAM role. Set the policy so it only trusts the exact Google service account ID of your app. Next, restrict the role permissions so it can only call the single model endpoint you need.

Network paths between the two clouds also need strict controls and monitoring. Public endpoints work with signed requests, but private links keep traffic off the public internet. Many teams set up a cross-cloud VPN or dedicated interconnect to route model traffic through private subnets.

Keep an eye on timeout limits on both sides of the request. Model inference can take several seconds when inputs are large or complex. Set your container request timeout slightly higher than the model endpoint timeout so errors return cleanly.

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

How should a Google Cloud container log in to AWS without static keys?

Use workload identity federation between Google Cloud and AWS IAM. The container trades its native Google identity token for short-lived AWS credentials at runtime.

How can we reduce latency between the web app and the model endpoint?

Pick cloud regions in the same geographic area, such as Northern Virginia on both clouds. Keep payloads small and reuse HTTP sessions across requests to skip repeated TLS handshakes.

How do we keep sensitive user data out of model request logs?

Filter and redact sensitive fields like emails, phone numbers, and card numbers before sending the payload. Also make sure your app logs only record request metadata and status codes, not raw user inputs.

The query runs. The emails stay hidden.