Configure service identity for jobs
Stay organized with collections
Save and categorize content based on your preferences.
A Cloud Run job has a service identity that is used
as the authenticated account for accessing Google Cloud APIs from your
Cloud Run instance container. To learn more about service identity,
see the Introduction to service identity
guide.
Service identity as a resource: To attach a service account as the
service identity, the deployer account
must have access on the service identity resource. Certain operations, like
creating or updating a job, require the deployer account to
have permissions on the service identity resource.
Service identity as a principal: To access Google Cloud APIs
from a Cloud Run job, you must grant the
service identity the required roles or permissions for the operations you want
your job to perform.
The next section covers the required roles for granting the deployer account
access on the service identity resource and granting the roles or permissions
that the service account principal needs.
Required roles
You or your administrator must grant IAM roles and permissions
for the deployer account and the service identity.
Click to view required roles for the deployer account
To get the permissions that you need to attach a service account as the
service identity on the job, you or your administrator
must grant your deployer account the
Service Account User
role (roles/iam.serviceAccountUser) on the service account
that is used as the service identity.
This predefined role contains the iam.serviceAccounts.actAs
permission, which is required to attach a service account on the
job. You might also be able to get this permission
by configuring custom roles
or using other predefined roles.
For instructions on how to grant the deployer account this role
on the service identity, see
deployment permissions.
If the service account is in a different project from the
Cloud Run job, you or your administrator
must also configure an IAM role for the
Cloud Run service agent and set up an org policy. See
use service accounts in other projects
for more details.
Click to view required roles for the service identity
To allow the service identity to access Google Cloud APIs from
Cloud Run, you or your administrator must grant the service
identity the permissions or roles
that are required by operations you want to perform. To accessing specific
Cloud Client Libraries, refer to the Google Cloud documentation for the
Google Cloud service.
If a Cloud Run job does not access
other Google Cloud services, you don't need to grant the service
identity any roles or permissions, and you can use the default service
account that was assigned to the project.
Get recommendations to create dedicated service accounts
When you create a new service account from the Google Cloud console, the optional
step "Grant this service account access to the project" is for any additional
access required. For example, one Cloud Run service might invoke
another
private Cloud Run service,
or it might access a Cloud SQL database, both
which require specific IAM roles. Refer to the documentation on
managing access
for more information.
The Recommender service also automatically
supplies recommendations to create a dedicated service accounts with the minimal
required set of permissions.
Configure service identity
To configure service identity in Cloud Run or specify, use either
the Google Cloud console, the gcloud CLI, or the API (YAML) when
you create and execute a new job:
Console
In the Google Cloud console, go to the Cloud Run Jobs page:
Click Deploy container to fill out
the initial job settings page. If you are configuring an existing job,
select the job, then click View and edit job configuration.
Click Containers, Connections, Security to expand the job properties page.
Click the Security tab.
Click the Service account dropdown and select
an existing service account, or click Create a new service account if
applicable.
Click Create or Update.
gcloud
You can create a new job
and specify service account by using the following command:
SERVICE_ACCOUNT: the service account associated with the
new identity. This value is the email address for the service account—for
example, example@myproject.iam.gserviceaccount.com.
You can update an existing job
to have a new service account by using the following command:
IMAGE_URL: a reference to the
container image—for
example, us-docker.pkg.dev/cloudrun/container/job:latest.
SERVICE_ACCOUNT: the service account associated with the
new identity. This value is the email address for the service account—for
example, SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com.
YAML
If you haven't already created a service account, you can either create a
user-managed service account in
IAM.
If you are creating a new job, skip this step.
If you are updating an existing job, download its YAML configuration:
SERVICE_ACCOUNT: the service account associated with
the new identity. This value is the email address for the service
account—for example,
SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com.
REGION: the Google Cloud region. For example,
europe-west1.
SERVICE_ACCOUNT: the service account associated with
the new identity. This value is the email address for the service
account—for example,
SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com.
Use service accounts in other projects
If you configure a service account from a different Google Cloud project
than the Cloud Run resource, do the following:
You or your administrator must grant the
Service Account User role (roles/iam.serviceAccountUser) on the
service account that you use as the service identity.
You or your administrator must grant the Cloud Run resource's
service agent the Service Account Token Creator role
(roles/iam.serviceAccountTokenCreator) on the service account
you use as the service identity. The service agent follows the format of
service-PROJECT_NUMBER@serverless-robot-prod.iam.gserviceaccount.com.
The project containing this service account requires the org-policy
iam.disableCrossProjectServiceAccountUsage to be set to
false or unenforced at the folder level or inherited from project-level
settings. By default, this is set to true.
If your Cloud Run service, job, or worker pool accesses Google APIs or
Google Cloud services, you must configure your service account as the
service identity. Learn more.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-09 UTC."],[],[]]