This guide covers how to set up your Google Cloud project and create service
account roles from the command-line utility.

For more details, see [Service account roles](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/service-accounts.md.txt).

## Set up the Cloud project

- Create a Google Cloud Project using the Google Cloud Console. Follow the
  basic instructions on the [Getting Started with Google Maps Platform](https://developers.google.com/maps/get-started.md.txt#create-project)

- Work with your Google sales representative to enable billing and the APIs
  for your specific service.

- Install the [Cloud CLI tool](https://cloud.google.com/sdk/docs/install) to complete the service
  configuration you started with your sales representative.

- Authenticate the CLI to your project.

**Note** : Consider using the Cloud Shell interactive environment where Cloud SDK
and other dependencies such as `**curl**` are already installed. See [Using
Cloud Shell](https://cloud.google.com/shell/docs/using-cloud-shell).

### shell

```bash
gcloud auth login
```

You should see a success message such as:

```bash
You are now logged in as [my-user@example.com].
Your current project is [project-id].  You ...
```

> [!NOTE]
> **Note:** Edit the variable values in code blocks to prepare subsequent commands so they can be directly copied and pasted.

Check that Fleet Engine APIs are configured appropriately.

### shell

```bash
gcloud --project=project-id services enable fleetengine.googleapis.com
```

If this command results in an error, check with your project administrator
and your Google support representative to get access.

## Create service accounts in the console

To create a service account, do the following:

1. Go to the [Google Cloud console](https://console.cloud.google.com/).
2. Find and click the **IAM \& Admin** card.
3. In the left-hand navigation, select **Service Accounts**.
4. At the top of the page, click **Create Service Account**.
5. Enter a service account name to display in the Google Cloud console. The Google Cloud console then generates a service account ID based on this name. For example, enter *fleet-engine-driver-sdk* for your Driver SDK User Service Account.
6. From the **Role** drop-down, select **Fleet Engine** and assign one of the roles to the service account.
7. Skip the **Grant users access to this service account** section.
8. Click **Done** to finish creating the service account.

See also [Create a service
account](https://cloud.google.com/iam/docs/service-accounts-create#creating)
.

## Create service accounts using the Google Cloud Command line utility

For example, create a service account for each of the three roles and assign
them their respective roles.

### On-demand trips roles

```
gcloud --project=project-id iam service-accounts create fleet-engine-admin
gcloud projects add-iam-policy-binding project-id \
       --member=serviceAccount:fleet-engine-admin@project-id.iam.gserviceaccount.com \
       --role=roles/fleetengine.ondemandAdmin

gcloud --project=project-id iam service-accounts create fleet-engine-driver-sdk
gcloud projects add-iam-policy-binding project-id \
       --member=serviceAccount:fleet-engine-driver-sdk@project-id.iam.gserviceaccount.com \
       --role=roles/fleetengine.driverSdkUser

gcloud --project=project-id iam service-accounts create fleet-engine-consumer-sdk
gcloud projects add-iam-policy-binding project-id \
       --member=serviceAccount:fleet-engine-consumer-sdk@project-id.iam.gserviceaccount.com \
       --role=roles/fleetengine.consumerSdkUser
```

### Scheduled tasks roles

```
gcloud --project=project-id iam service-accounts create fleet-engine-admin
gcloud projects add-iam-policy-binding project-id \
       --member=serviceAccount:fleet-engine-admin@project-id.iam.gserviceaccount.com \
       --role=roles/fleetengine.deliveryAdmin

gcloud --project=project-id iam service-accounts create fleet-engine-driver-sdk
gcloud projects add-iam-policy-binding project-id \
       --member=serviceAccount:fleet-engine-driver-sdk@project-id.iam.gserviceaccount.com \
       --role=roles/fleetengine.deliveryUntrustedDriver

gcloud --project=project-id iam service-accounts create fleet-engine-consumer-sdk
gcloud projects add-iam-policy-binding project-id \
       --member=serviceAccount:fleet-engine-consumer-sdk@project-id.iam.gserviceaccount.com \
       --role=roles/fleetengine.deliveryConsumer
```

## What's next

- [Issue JSON Web Tokens](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/issue-jwt.md.txt)