create-service-account Stay organized with collections Save and categorize content based on your preferences.
Creates Google Cloud service accounts with roles that allow individual Apigee hybrid components to make authorized API calls and downloads the associated service account key files. You can use the service account key files generated by this command in your configuration overrides file.
create-service-account creates one or more service accounts in your current Google Cloud project or the project you specify, assigns the correctIAM role to the service account, and downloads the certificate file for the service account into a directory on your local machine.
Thecreate-service-account tool is located in theHYBRID_ROOT_DIR/tools directory.
To learn more about service accounts and read the full list of service accounts recommended for production environments, see the following:
You can also create service accounts in the Google Cloud console. See alsoCreating and managing service accounts.
Prerequisites
Role
Thecreate-service-account tool requires that thegcloud CLI be installed. Users invoking the utility should have the roleService Account Admin.
Project
Service accounts are bound to a specific Google Cloud project.create-service-account creates service accounts in your current project or in the project you specify, and binds the IAM roles to the service accounts within that project.create-service-account also uses the Project ID as part of the service account key file name and email. For example, if your project is namedmy-hybrid-project, the apigee-logger service account key file will be namedmy-hybrid-project-apigee-logger.json and the service account's email address will beapigee-logger@my-hybrid-project.iam.gserviceaccount.com.
You can specify a project by defining aPROJECT_ID environment variable or with the--project-id flag.create-service-account reads the value of thePROJECT_ID environment variable. If it is not present, you can use the--project-id flag.
If you do not specify a Cloud project ID with the command,create-service-account uses the project in your current gcloud project configuration.
You can check current setgcloud project configuration with the following command:
gcloud config list project
If you need to change the current project ID, use the following command:
gcloud config set projectPROJECT_ID
WherePROJECT_ID is the ID of your current Cloud project. Instructions for creating a Cloud Project are covered inStep 2: Create a Google Cloud project.
Usingcreate-service-account
The following examples show usingcreate-service-account for common Apigee hybrid setup tasks.
Create service accounts for a production environment
In a production hybrid environment Apigee recommends using a separate service account for each component. Use the following command to create all the service accounts for the hybrid components with their default names in the default directory.
./tools/create-service-account --env prod
This will create the following service accounts with the cert files downloaded in the./tools/service-accounts directory:
| Service account | IAM role | Cert file | |
|---|---|---|---|
apigee-cassandra | roles/storage.objectAdmin | apigee-cassandra@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-cassandra.json |
apigee-logger | roles/logging.logWriter | apigee-logger@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-logger.json |
apigee-mart | roles/apigeeconnect.Agent | apigee-mart@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-mart.json |
apigee-metrics | roles/monitoring.metricWriter | apigee-metrics@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-metrics.json |
apigee-runtime | No role assigned | apigee-runtime@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-runtime.json |
apigee-synchronizer | roles/apigee.synchronizerManager | apigee-synchronizer@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-synchronizer.json |
apigee-udca | roles/apigee.analyticsAgent | apigee-udca@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-udca.json |
apigee-watcher | roles/apigee.runtimeAgent | apigee-watcher@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-watcher.json |
Create a single service account for a non-production environment
For non-production environments, like an experimental or demo environment, you can create a single service account named "apigee-non-prod" that you can use for all components. This service account will have all the IAM roles in the previous example assigned to it.
./tools/create-service-account --env non-prod
This will create as single service account namedapigee-non-prod and download the cert file in the./tools/service-accounts directory:
| Service account | IAM roles | Cert file | |
|---|---|---|---|
apigee-non-prod | roles/apigee.analyticsAgent | apigee-non-prod@PROJECT_ID.iam.gserviceaccount.com | PROJECT_ID-apigee-non-prod.json |
create-service-account syntax
Thecreate-service-account tool uses the following syntax:
create-service-account [flags]
The following table lists thecreate-service-account flags:
| Flag | Values | Description |
|---|---|---|
--dir-d | directory name | Specifies an output directory for the service account key files. If the directory does not exist,create-service-account will create it. If the directory already exists,create-service-account will overwrite any files in the directory that have the same name as the key files it is creating. If you do not specify an output directory, |
--env-e | prodnon-prod | Specifies if you are creating service accounts for a production (prod) environment or a non-production (non-prod) environment.
If you run |
--help-h | none | Displays help text. |
--name-n | service account name | Specifies a name for the service account.--name only applies to a single service account, either specified with--profile or--env non-prod. The name is also part of the cert file name and email for the service account. For example if you run
If you do not specify |
‑‑profile-p | apigee‑cassandraapigee‑loggerapigee‑martapigee‑metricsapigee‑runtimeapigee‑synchronizerapigee‑udcaapigee‑watcher | For production environments only, specifies a single service account to create. You can specify a name for the service account with the Requires |
‑‑project‑id-i | project id | The Project ID of the Google Cloud project in which you are creating the service accounts.
If you do not specify a Project ID, |
create-service-account tool cannot create theapigee-org-admin service account used to enable synchronizer access to. To do that, you must use theGoogle Cloud Platform console or thegCloud APIs.For more information about the service accounts used by Apigee hybrid, seeAbout service accounts.
You can also create service accounts in the Google Cloud console. See alsoCreating and managing service accounts.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.