> [!CAUTION]
> You are currently viewing version 1.7 of the Apigee hybrid documentation. **This version is end of life.** You should upgrade to a newer version. For more information, see [Supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions).

<button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">Version 1.7 (unsupported)</button>

- Supported versions:
- [v1.17 (latest)](https://docs.cloud.google.com/apigee/docs/hybrid/v1.17/install-service-accounts.md.txt)
- [v1.16](https://docs.cloud.google.com/apigee/docs/hybrid/v1.16/install-service-accounts.md.txt)
- [v1.15](https://docs.cloud.google.com/apigee/docs/hybrid/v1.15/install-service-accounts.md.txt)
- [v1.14](https://docs.cloud.google.com/apigee/docs/hybrid/v1.14/install-service-accounts.md.txt)
- [List of supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions)
- Unsupported versions:
- [v1.13](https://docs.cloud.google.com/apigee/docs/hybrid/v1.13/install-service-accounts.md.txt)
- [v1.12](https://docs.cloud.google.com/apigee/docs/hybrid/v1.12/install-service-accounts.md.txt)
- [v1.11](https://docs.cloud.google.com/apigee/docs/hybrid/v1.11/install-service-accounts.md.txt)
- [v1.10](https://docs.cloud.google.com/apigee/docs/hybrid/v1.10/install-service-accounts.md.txt)
- [v1.9](https://docs.cloud.google.com/apigee/docs/hybrid/v1.9/install-service-accounts.md.txt)
- [v1.8](https://docs.cloud.google.com/apigee/docs/hybrid/v1.8/install-service-accounts.md.txt)
- [v1.7](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-service-accounts.md.txt)
- [v1.6](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/install-service-accounts.md.txt)
- [v1.5](https://docs.cloud.google.com/apigee/docs/hybrid/v1.5/install-service-accounts.md.txt)
- [v1.4](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/install-service-accounts.html)
- [v1.3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.3/install-service-accounts.html)
- [v1.2](https://docs.cloud.google.com/apigee/docs/hybrid/v1.2/install-service-accounts.html)
- [v1.1](https://docs.cloud.google.com/apigee/docs/hybrid/v1.1/install-service-accounts.html)

This step explains how to create the Google Cloud service accounts and TLS credentials
that are required for Apigee hybrid to operate.

## Create the service accounts


Apigee hybrid uses Google Cloud [service accounts](https://docs.cloud.google.com/iam/docs/service-accounts) to
allow hybrid components to communicate by making authorized API calls.


In this step, you use an Apigee hybrid command-line tool to create a set of service accounts
and download the service account private key files.

> [!NOTE]
> **Note:** In a production hybrid environment Apigee recommends using a separate service account for each component. For the purposes of this tutorial, you can create a single service account named "apigee-non-prod" that you can use for all components.
>
>
> To learn more about service accounts and read the full list of service accounts recommended for
> production environments, see the following:
>
> - [About service accounts](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/sa-about.md.txt)
> - [Service accounts and roles used by hybrid components](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/sa-about.md.txt#recommended-sas)


Apigee provides a tool, `create-service-account`, that creates the service accounts,
assigns the roles to the service accounts, and creates and downloads the key files for the service
account in a single command.

- To learn more about `create-service-account` and all its options see [`create-service-account`](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/create-service-account.md.txt)
- To learn about the related Google Cloud concepts, see [Creating
  and managing service accounts](https://cloud.google.com/iam/docs/creating-managing-service-accounts) and [Creating
  and managing service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys).

1. Be sure that you are in the `base_directory/hybrid-files` directory you configured in [Set up the project directory structure](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-service-accounts.md.txt#setup-directory).
2. Make sure your **PROJECT_ID** environment variable is set to your Google cloud project ID. The `create-service-account` tool reads the **PROJECT_ID** environment variable to create the service accounts in the correct project.

   ```
   echo $PROJECT_ID
   ```
3. Execute the following command from inside the `hybrid-files` directory. This command creates a single service account named `apigee-non-prod` for use in non-production environments and places the downloaded key file in the `./service-accounts` directory.

   ```
   ./tools/create-service-account --env non-prod --dir ./service-accounts
   ```

   > [!NOTE]
   > **Note:** If you would prefer to create all the individual service accounts for a production environment, use the following command:
   >
   > ```
   > ./tools/create-service-account --env prod --dir ./service-accounts
   > ```


   If you see the following prompt, enter <kbd>y</kbd>:

   ```
   [INFO]: gcloud configured project ID is project_id.
    Enter: y to proceed with creating service account in project: project_id
    Enter: n to abort.
   ```


   If this is the first time you are creating an SA with a particular name assigned, then the
   tool creates it without further prompts.


   If, however, you see the following message and prompt, enter <kbd>y</kbd> to generate
   new keys:

   ```
   [INFO]: Service account apigee-non-prod@project_id.iam.gserviceaccount.com already exists.
   ...
    [INFO]: The service account might have keys associated with it. It is recommended to use existing keys.
    Press: y to generate new keys.(this does not deactivate existing keys)
    Press: n to skip generating new keys.
   ```

   > [!NOTE]
   > **Note:** The Cloud Pub/Sub API must be enabled in the Google Cloud project that owns the service account for Synchronizer. See [Enable APIs](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/precog-enableapi.md.txt).

4. Verify that the service account key was created using the following command. You are responsible for storing these private keys securely. The key filenames are prefixed with the name of your Google Cloud project.

   ```
   ls ./service-accounts
   ```


   The result should look something like the following:

   ```
   project_id-apigee-non-prod.json
   ```

> [!NOTE]
> **Tip:** Apigee hybrid includes a validator that checks your service accounts' key files and permissions when [apigeectl](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/cli-reference.md.txt) applies the Apigee hybrid runtime components to your cluster. This validation is enabled by default. For more information, see [Service account
> validation](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/sa-validation).


You now have created service accounts and assigned the roles needed by the Apigee hybrid
components. Next, the TLS certificates required by the hybrid ingress gateway..
[1](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-create-cluster.md.txt) [2](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-cert-manager.md.txt) [3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-asm.md.txt) [4](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-apigeectl.md.txt) [5](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-service-accounts.md.txt) [(NEXT) Step 6: Create TLS certificates](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-create-tls-certificates.md.txt) [7](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-configure-cluster.md.txt) [8](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-enable-synchronizer-access.md.txt) [9](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/install-hybrid-runtime.md.txt)

<br />