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

Published
Length
3 min read

Luis Felipe Dias

All posts

You link google pub/sub and step functions to trigger cross-cloud tasks from event streams. A message lands in a Google topic and starts an AWS state machine run. Many teams run data pipelines in Google Cloud and app logic in AWS. Joining these two services lets you process events across clouds without manual work. You can move order data, user signups, or billing alerts from one cloud to another. The setup needs clear identity rules, safe network paths, and good error handling. How google pu

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.

You link google pub/sub and step functions to trigger cross-cloud tasks from event streams. A message lands in a Google topic and starts an AWS state machine run.

Many teams run data pipelines in Google Cloud and app logic in AWS. Joining these two services lets you process events across clouds without manual work. You can move order data, user signups, or billing alerts from one cloud to another. The setup needs clear identity rules, safe network paths, and good error handling.

How google pub/sub and step functions share data and permissions

These two tools live in different clouds, so they cannot share a native role. You must set up cross-cloud trust before any data can move between them. Workload identity federation is the safest way to link the two cloud accounts. This method lets your compute job trade a Google token for temporary AWS rights.

You have two main ways to move messages from the topic to the workflow. First, you can use a push subscription that sends data to an HTTPS endpoint. Second, a small worker job can pull messages and start the state machine. Both paths need strict permission checks on every single request.

In a push setup, the topic sends an HTTP post to an AWS endpoint. An API layer or function checks the token and starts the state machine run. In a pull setup, a small worker reads from the subscription on a schedule. That worker assumes an AWS role and calls the state machine start API.

Keep the message payload small when you pass it into the state machine. State machines have strict size limits on the input data they can take. If you have large files, save them in cloud storage first. Then pass only the file location inside the event message.

Common failure modes and how to scope roles

The biggest risk in cross-cloud setups is using static, long-lived secret keys. Teams often create an IAM user key and paste it into a worker script. If that key leaks, an attacker can run workflows or read data at will. Shared service accounts also make it hard to see who triggered a specific run.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad roles create another major risk for your production apps. A worker job should never have permission to start every workflow in your account. Give the role permission to start only the exact state machine it needs. On the Google side, scope the reader role to one specific subscription.

Network paths and retry rules can also break your pipeline if left unchecked. If a state machine fails to start, the topic will retry the message delivery. Without a dead-letter topic, bad messages will loop and run up your cloud bill. Set a clear retry limit and route failed events to a dead-letter queue.

You also need to handle duplicate messages across the cloud boundary. Event queues send messages at least once, so duplicates will happen during network blips. Use the unique message ID from the topic as the state machine run name. This simple rule stops the workflow from running twice for the same event.

Finally, check what data lives inside the event payload before you log it. State machine execution histories often record the full input and output of every step. If events carry emails, phone numbers, or card numbers, those details stay in logs. Data masking rewrites matched fields in results so sensitive strings do not leak.

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 a Google topic trigger an AWS state machine without a middle worker?

Not directly, because the topic push feature cannot sign requests with AWS headers. You need a small HTTPS function or API endpoint to receive the push request. That endpoint checks the Google token and starts the state machine run.

How do I stop duplicate messages from starting two workflow runs?

Every message in the topic comes with a unique ID string. Pass this ID as the execution name when you start the state machine. AWS will reject a second start call that uses the same execution name.

What is the safest way to handle credentials between the two clouds?

Never create or store static IAM access keys in your code or config files. Use OpenID Connect identity federation to trade short-lived tokens across the two clouds. This setup removes the need to rotate or hide permanent secret keys.

The query runs. The emails stay hidden.