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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use cloud sql and step functions to run cross-cloud database tasks in order. AWS state machines trigger tasks that read or write records in Google databases. Many teams store raw data in Google Cloud. They also run workflow apps in AWS. Linking these two systems lets you automate billing, reporting, and cleanup jobs. Yet cross-cloud setups create big risks if you share static passwords or wide roles. How cloud sql and step functions move data and check roles A state machine in AWS does

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 sql and step functions to run cross-cloud database tasks in order. AWS state machines trigger tasks that read or write records in Google databases.

Many teams store raw data in Google Cloud. They also run workflow apps in AWS. Linking these two systems lets you automate billing, reporting, and cleanup jobs. Yet cross-cloud setups create big risks if you share static passwords or wide roles.

How cloud sql and step functions move data and check roles

A state machine in AWS does not talk to a Google database on its own. Instead, a step in the workflow calls a compute task or worker function. That worker opens a network path to the database instance. It logs in, runs the query, and sends the result back to the workflow.

You must set up database users with care on the Google side. Cloud SQL for PostgreSQL is a managed service. Because of this, you cannot create or use accounts with full superuser rights. A system account owned by Google holds the real superuser role. You cannot change or delete these system accounts.

Instead, you get a default admin user named postgres. This user starts with no password, so you must set one before logging in. It belongs to a special group called cloudsqlsuperuser. This group lets you add extensions, make event triggers, and set up replication. The default postgres user can also make new roles and databases. Your AWS workflow workers should never use this high-level admin account.

Common failure modes in cross-cloud database workflows

The biggest mistake teams make is sharing one database login across many workflows. When five state machines use the same password, you lose track of who ran what. If a bad step drops a table, your logs only show the shared account name. You cannot tell which workflow or team caused the outage.

Broad permissions make this problem much worse. If a workflow only needs to read order totals, it should not have write rights. Giving the cloudsqlsuperuser role to an automated job puts every table at risk. A bug in one state machine could wipe out data for other apps.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Network paths across cloud providers also fail when teams take shortcuts. Opening a database to public internet traffic invites attacks. Teams should route traffic over private cross-cloud links and lock down firewall rules. Each worker task should only reach the exact database port it needs.

Sensitive data in query results creates another huge risk. Workflows often pass query outputs from one step to the next. If a query returns emails, phone numbers, card numbers, or national IDs, those values sit in state logs. Anyone who reads the workflow execution history can see that private data.

Scoping database roles and securing workflow steps

Start by making a separate database role for each workflow task. Use the default admin user only to create these smaller, restricted roles. Grant read rights on specific tables to reporting steps. Grant write rights only to the exact tables that an update step must change.

Next, stop hardcoding database passwords inside state machine definitions or worker code. Rotate keys often and keep their lifespan short. Make sure every query gets logged with the name of the workflow that ran it. Also, use data masking so the system rewrites matched fields in results before they reach workflow logs. This keeps card numbers and emails out of your AWS state history.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can a Step Functions state machine use a true PostgreSQL superuser in Cloud SQL?

No, customers cannot create or use true superuser accounts in this managed service. You can only use the cloudsqlsuperuser role, and workflow tasks should use much smaller roles.

Why should workflow tasks avoid the default postgres user?

The default postgres user can create databases, make roles, and manage replication. Using it for routine workflow queries gives your automated jobs far too much power.

How do we keep private data out of Step Functions execution logs?

Limit queries to non-sensitive columns whenever you can. For queries that touch private tables, apply masking that rewrites matched fields in results like emails or card numbers.

The query runs. The emails stay hidden.