You know the pain. A containerized service needs to query Amazon Redshift, but security teams clutch their pearls at the idea of hardcoded credentials. Connecting Cloud Run to Redshift can feel like threading a needle through IAM, networking, and OIDC—with one hand tied behind your back. Yet this pairing is powerful when done right.
Google Cloud Run excels at stateless microservices running on demand, no servers to babysit. Amazon Redshift, on the other hand, is a heavyweight analytical database that loves crunching terabytes of data. Combine them and you get lightweight compute calling heavyweight data. The trick is doing it without leaking secrets or creating a permission mess.
At its best, Cloud Run to Redshift means your service authenticates through short-lived AWS credentials generated on the fly. No static keys, no shared tokens. The usual workflow uses Google’s Workload Identity Federation (WIF) to let Google-issued identities assume roles in AWS. Redshift sits behind standard AWS IAM policies that check those roles before granting a session. Once authenticated, your Cloud Run service connects over HTTPS or JDBC and runs SQL directly against Redshift.
If you need a 60-second summary: To connect Cloud Run to Redshift securely, use Workload Identity Federation to exchange a Google-issued token for temporary AWS credentials, then connect to Redshift with those credentials and standard IAM role permissions.
Here’s how the flow works:
- Cloud Run service account is trusted by a Google Workload Identity Pool.
- That pool maps to an AWS IAM role configured for Redshift access.
- When Cloud Run runs, it fetches a short-lived credential set via OIDC.
- The AWS role verifies the token, Redshift trusts the connection.
- The service runs queries, and credentials expire automatically.
It’s elegant when you see it run, almost boringly simple once policies are correct. The common errors are misaligned audience claims in the OIDC token or mismatched role trust policies. Always verify your OIDC provider configuration in AWS IAM before testing. Secure it with the principle of least privilege, and rotate or revoke tokens promptly.