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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair google pub/sub and sagemaker to stream events into machine learning models. This setup moves live data from Google Cloud into AWS for fast predictions. Many apps create event data in Google Cloud while data teams build models in AWS. A clean bridge between the two clouds keeps your data pipeline fast and safe. Without clear rules, cross-cloud pipelines often suffer from leaked keys and broken logs. How google pub/sub and sagemaker share data and identity Moving data across clouds

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 sagemaker to stream events into machine learning models. This setup moves live data from Google Cloud into AWS for fast predictions.

Many apps create event data in Google Cloud while data teams build models in AWS. A clean bridge between the two clouds keeps your data pipeline fast and safe. Without clear rules, cross-cloud pipelines often suffer from leaked keys and broken logs.

How google pub/sub and sagemaker share data and identity

Moving data across clouds starts with a trust link between both accounts. You should avoid saving static AWS keys inside your Google Cloud project. Instead, set up workload identity federation between Google Cloud and AWS IAM. A worker service reads messages from a Pub/Sub subscription using its Google identity. That worker exchanges its Google token for a temporary AWS role token. With that token, the worker sends payload data to the model endpoint.

You can also use push subscriptions if an intermediate web service handles AWS signing. Pull workers work best when you need batching or custom error handling. When the model finishes its run, the worker writes results to storage or another topic. Each step uses short-lived credentials that expire after a few minutes.

Common failure modes in cross-cloud pipelines

The biggest risk in a two-cloud setup is a shared service account. Teams often create one broad role for all developers and background jobs. If a key leaks, an attacker can read every topic and call any model. Shared accounts also ruin your audit logs during a security review. You cannot tell which engineer or app sent a specific payload.

Another common issue is sending raw user data straight to model endpoints. Event streams often contain emails, phone numbers, card numbers, or national IDs. If a worker logs the full request body, those fields land in plain text logs. Masking rewrites matched fields in results before logs or non-production tools store them.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Network paths between clouds also fail when teams open public endpoints without strict rules. You should lock down endpoint access to specific IAM roles and known network ranges. Give each Pub/Sub subscription its own reader role with zero extra permissions. Give each model endpoint an invocation role that only calls that single model.

Scoping roles and network paths for production

Start by mapping each data stream to a single business purpose. Create one Google service account for the worker that reads a single subscription. Link that account to one AWS IAM role through identity federation. Set the AWS role policy so it can only invoke one target model.

Next, check how engineers test and debug the pipeline during daily work. Developers often need to inspect dead-letter messages or test a model endpoint by hand. Do not give developers the same long-lived keys that legacy scripts use. Require every engineer to log in through your identity provider for each session. Log every read and model call with the user identity, timestamp, and target name. This gives your security team a clear record of every action across both clouds.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can Google Pub/Sub push messages straight to a SageMaker endpoint?

No, because AWS endpoints require specific cryptographic request headers on every call. You need a lightweight worker or function to sign the request using temporary AWS credentials.

How do we avoid storing AWS access keys in Google Cloud?

Use workload identity federation between Google Cloud and AWS IAM. Your Google service account trades its native identity token for a short-lived AWS session token.

How should we handle failed predictions in the message stream?

Attach a dead-letter topic to your Pub/Sub subscription to catch failed messages. Set a maximum delivery count so bad payloads move aside for safe inspection.

The query runs. The emails stay hidden.