> [!WARNING]
>
> **Preview**
>
>
> This product or feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section
> of the [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA products and features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

Like many Google Cloud services, Developer Device Platform has a dedicated [service
agent](https://docs.cloud.google.com/iam/docs/service-account-types#service-agents). This page explains how
the DDP service agent works, what it can do, and how you can share resources
with it.

## Permissions

When DDP is used for a project the first time, the system creates a service
agent-type service account named
`service-PROJECT_NUMBER@gcp-sa-devicerun.iam.gserviceaccount.com`, where `PROJECT_NUMBER` is the numeric project
number of the Google Cloud project initiating the Device Run
session.

When you enable the [Device Run](https://docs.cloud.google.com/developer-device-platform/device-run.md.txt) API
([devicerun.googleapis.com](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest.md.txt)),
Google Cloud automatically provisions the service agent and assigns it the
[roles/devicerun.serviceAgent](https://docs.cloud.google.com/iam/docs/service-agents.md.txt#device-run-service-agent)
role at the project level.

This service agent is granted permission to the Google Cloud project in which
the Developer Device Platform is launched. The service agent uses its own
credentials to perform file transfers on your behalf:

- Read and write to Cloud Storage buckets and objects
- Download Cloud Storage input files to the internal system
- Upload files from the internal system to the Cloud Storage output bucket

Both the calling principal (user or service account) and the DDP service agent
require Cloud Storage permissions on referenced buckets:

- **Caller permissions** : The principal calling `CreateSession` must directly hold permissions on every Cloud Storage bucket referenced in the request. See [Caller permissions](https://docs.cloud.google.com/developer-device-platform/device-run/share-storage.md.txt#caller-permissions).
- **Service agent permissions** : If a Cloud Storage bucket is owned by a different Google Cloud project than the one used in DDP, or has bucket-level access restrictions, the DDP service agent might not have access to it. See [Sharing access with the service agent](https://docs.cloud.google.com/developer-device-platform/device-run/share-storage.md.txt#sharing-access).

## Caller permissions

Starting January 18, 2027, Device Run requires the calling principal
(user or service account) of `CreateSession` requests to have direct
Cloud Storage permissions on all referenced buckets, in addition to the DDP
service agent:

- **Input buckets** (test binaries, APKs, IPAs, and pushed files): `storage.objects.get` --- for example, [Storage Object Viewer (`roles/storage.objectViewer`)](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt#storage.objectViewer).
- **Output buckets** : `storage.objects.create` and `storage.objects.delete` --- for example, [Storage Object User (`roles/storage.objectUser`)](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt#storage.objectUser).
- **Smart-sharding buckets** : `storage.objects.get`, `storage.objects.create`, and `storage.objects.delete` --- for example, [Storage Object User (`roles/storage.objectUser`)](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt#storage.objectUser).

For example, to grant a calling service account access to specific buckets:

```bash
gcloud storage buckets add-iam-policy-binding gs://INPUT_BUCKET_NAME \
  --member="serviceAccount:CALLER_SERVICE_ACCOUNT" \
  --role="roles/storage.objectViewer"

gcloud storage buckets add-iam-policy-binding gs://OUTPUT_BUCKET_NAME \
  --member="serviceAccount:CALLER_SERVICE_ACCOUNT" \
  --role="roles/storage.objectUser"
```

## Sharing access with the service agent

See [Device Run](https://docs.cloud.google.com/developer-device-platform/device-run.md.txt) for how to include files with your tests in the
DDP-supported project. If your Cloud Storage bucket resides in a different
Google Cloud project from your DDP project and you want Device Run to
be able to *read* these files, you must grant
[roles/storage.objectViewer](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt#storage.objectViewer)
to the service agent of the project where the DDP request is initiated as
described here.

*Grant Storage Object Viewer to the service agent* : Ensure the DDP Service Agent
has the `Storage Object Viewer` (`roles/storage.objectViewer`) role on the
Cloud Storage bucket containing the files:

```bash
gcloud storage buckets add-iam-policy-binding gs://<var>BUCKET_NAME</var> \
    --member="serviceAccount:service-<var>PROJECT_NUMBER</var>@gcp-sa-devicerun.iam.gserviceaccount.com" \
    --role="roles/storage.objectViewer"
```

> [!CAUTION]
> **Caution:** You may also grant the [roles/storage.objectUser](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt#storage.objectUser) role to the DDP service agent to *upload* to Google Cloud; but we recommend against placing output files into buckets outside of the project where DDP was triggered.

## Validation

Now return to your workflow and ensure [Device Run](https://docs.cloud.google.com/developer-device-platform/device-run.md.txt) has access
to the requisite files. If either the calling principal (user or service
account) or the DDP service agent does not have access to the specified buckets,
the session fails to start.

## Supporting documentation

- [Types of service accounts: service
  agents](https://docs.cloud.google.com/iam/docs/service-account-types#service-agents) - Learn how service agents operate within Google Cloud
- [Service Agents](https://docs.cloud.google.com/iam/docs/service-agents.md.txt) - See every Google Cloud service agent
- [Cloud Storage roles and permissions](https://docs.cloud.google.com/iam/docs/roles-permissions/storage.md.txt) - Find all Cloud Storage-related roles and permissions