Native Google OIDC authentication to private Cloud Run services requires a Google-recognized identity for
restate-server: either an ambient GCP workload identity, or an AWS identity federated into your Google Cloud project through a workload identity provider.
Restate Cloud environments in the public AWS regions use workload identity federation. See Connect a private Cloud Run service to Restate Cloud for the setup.Set up your service on Cloud Run
Package your Restate service as a container image and deploy it to Cloud Run following the Cloud Run documentation. A typical Restate service exposes its handler on port9080; configure the Cloud Run service to forward traffic to whichever port your container listens on.
Restate’s service deployment protocol uses HTTP/2 (h2c), so the Cloud Run service must use end-to-end HTTP/2 to the container. Enable it when you deploy with --use-http2 (equivalently, the run.googleapis.com/use-http2 annotation); without it, discovery and invocation fail with an upstream protocol error.
Connect a private Cloud Run service to Restate Cloud
Restate Cloud environments in the public AWS regions can invoke private Cloud Run services without any stored Google credentials. Restate Cloud federates your environment’s AWS identity into your Google Cloud project through workload identity federation, and every grant lives in your project’s IAM, so you can audit and revoke the access at any time. Public (--allow-unauthenticated) Cloud Run services do not need this setup. Secure them with Restate request signing like any other public endpoint.
This setup requires the restate CLI v1.8.0 or later.
How the environment identity works
Google Cloud sees your Restate Cloud environment as one fixed AWS principal:<RESTATE_AWS_ACCOUNT_ID> is the AWS account that hosts your environment’s region, and <ENVIRONMENT_NAMESPACE> is your environment ID with the env_ prefix replaced by env- (for example, env_201abc... becomes env-201abc...).
Copy the exact account ID and subject for your environment from Developers > Security > Google Cloud Run in the Restate Cloud UI, which also shows the commands below prefilled.
You grant this subject permission to mint ID tokens as a Google service account that you own, and you grant that service account permission to invoke your Cloud Run service.
Because the subject includes your environment ID, no other Restate Cloud environment can mint tokens as your service account.
To separate environments, such as staging and production, bind each environment’s subject to its own service account.
Create a workload identity pool and provider
Create a pool and an AWS provider in your Google Cloud project once. The provider trusts the Restate Cloud AWS account and is pinned to the Restate Cloud federation role. The token exchange calls the IAM, IAM Service Account Credentials, and Security Token Service APIs, so enable them first. Without them, registration fails with a403 SERVICE_DISABLED that retrying does not fix:
--attribute-condition is required. It ensures that only the Restate Cloud federation role, and no other principal in that AWS account, can federate through your provider.
Allow your environment to mint ID tokens
Create the service account that Restate will impersonate to invoke your Cloud Run service, if you don’t have one yet:403 PERMISSION_DENIED on iam.serviceAccounts.getOpenIdToken.
Allow the service account to invoke your service
403 Forbidden from Cloud Run during discovery.
Register the deployment
Register your Cloud Run service with the provider you created and the service account to impersonate:--gcp-audience only if your service sits behind a custom domain or load balancer, as described in Custom domains and audience overrides.
Registration sends a discovery request through the full authentication chain, so a successful registration confirms that authentication works end to end.
After registration, Restate Cloud mints, caches, and refreshes tokens automatically. Authorization failures, for example after you revoke a grant, appear as invocation errors that include the Google error detail.
Register the service with native authentication
When registering an HTTP deployment, opt into native Google OIDC authentication with--gcp-id-token. Restate mints a Google-signed ID token for every discovery and invocation request and attaches it as X-Serverless-Authorization: Bearer <token>. Cloud Run validates this header in precedence over Authorization and strips it before forwarding the request to your container, so any Authorization value you set via --extra-header reaches the workload unchanged.
generateIdToken API:
--gcp-impersonate-service-account implies --gcp-id-token.
Custom domains and audience overrides
By default, Restate derives the OIDCaud claim from the deployment URL origin (scheme, host, and optional port). If your Cloud Run service sits behind a custom domain, a load balancer, or a traffic tag, set the audience explicitly to the canonical Cloud Run service URL:
--gcp-audience also implies --gcp-id-token.
Updating or removing authentication
Authentication configuration is set when the deployment is registered. To rotate the impersonation target, change the audience, or remove authentication entirely, re-register with--force:
--force re-runs discovery against the deployment, so the new configuration must itself be able to reach the service. Removing authentication from a service that still requires authenticated invocations therefore fails at discovery with 403 Forbidden; only remove authentication once the service accepts the request without a token.
Credentials available to Restate
Restate discovers credentials through Google’s Application Default Credentials (ADC) chain. Not every ADC source can mint an OIDC ID token directly; the table below summarizes what works.
When the ambient identity cannot mint ID tokens for arbitrary audiences, pair it with
--gcp-impersonate-service-account so Restate calls the IAM Credentials generateIdToken API on a target service account that the ambient identity is authorized to impersonate.
AWS-hosted Restate: workload identity federation
A Restate server whose ambient identity is an AWS identity (such as Restate Cloud, or a self-hosted deployment on EKS/EC2) can mint Google ID tokens without any Google credential, by exchanging a signed AWS identity assertion through a workload identity federation provider in your Google Cloud project. Register with the provider’s full resource name, always paired with a service account to impersonate:worker.invoker.gcp-federation in the server configuration); the provider you create must trust that role, and the impersonation grant is made to the resulting federated subject. On Restate Cloud this is preconfigured. Follow Connect a private Cloud Run service to Restate Cloud for the trust setup.
IAM roles
The principal whose identity ends up in the minted token must hold:roles/run.invokeron the target Cloud Run service, so that Cloud Run IAM accepts the request.roles/iam.serviceAccountOpenIdTokenCreatoron the impersonation target, when--gcp-impersonate-service-accountis used.
Self-hosted Restate
For self-hosted Restate calling private Cloud Run services, ensure one of the following:- The Restate process can reach Google’s metadata server (typical on GCE, GKE, or Cloud Run hosts), or
GOOGLE_APPLICATION_CREDENTIALSpoints to a service-account JSON key file readable by the Restate user.
Local development
For local development, rungcloud auth application-default login to populate ADC. This is distinct from gcloud auth login, which only populates user credentials for the gcloud tool itself.
Authorized-user ADC credentials cannot mint ID tokens for arbitrary audiences without impersonation, so pair them with --gcp-impersonate-service-account for the dev flow.
Token caching and rotation
Credentials are cached per identity —(workload identity provider, impersonated service account, audience) — and shared across discovery and invocations. Each cached credential refreshes its token proactively in the background, so steady-state requests never wait on a mint. Idle credentials are evicted after an hour of disuse and rebuilt transparently on the next request.