> [!CAUTION]
> You are currently viewing version 1.6 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.6 (unsupported)</button>

- Supported versions:
- [v1.17 (latest)](https://docs.cloud.google.com/apigee/docs/hybrid/v1.17/precog-add-environment.md.txt)
- [v1.16](https://docs.cloud.google.com/apigee/docs/hybrid/v1.16/precog-add-environment.md.txt)
- [v1.15](https://docs.cloud.google.com/apigee/docs/hybrid/v1.15/precog-add-environment.md.txt)
- [v1.14](https://docs.cloud.google.com/apigee/docs/hybrid/v1.14/precog-add-environment.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/precog-add-environment.md.txt)
- [v1.12](https://docs.cloud.google.com/apigee/docs/hybrid/v1.12/precog-add-environment.md.txt)
- [v1.11](https://docs.cloud.google.com/apigee/docs/hybrid/v1.11/precog-add-environment.md.txt)
- [v1.10](https://docs.cloud.google.com/apigee/docs/hybrid/v1.10/precog-add-environment.md.txt)
- [v1.9](https://docs.cloud.google.com/apigee/docs/hybrid/v1.9/precog-add-environment.md.txt)
- [v1.8](https://docs.cloud.google.com/apigee/docs/hybrid/v1.8/precog-add-environment.md.txt)
- [v1.7](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/precog-add-environment.md.txt)
- [v1.6](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/precog-add-environment.md.txt)
- [v1.5](https://docs.cloud.google.com/apigee/docs/hybrid/v1.5/precog-add-environment.md.txt)
- [v1.4](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/precog-add-environment.md.txt)
- [v1.3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.3/precog-add-environment.md.txt)
- [v1.2](https://docs.cloud.google.com/apigee/docs/hybrid/v1.2/precog-add-environment.md.txt)
- [v1.1](https://docs.cloud.google.com/apigee/docs/hybrid/v1.1/precog-add-environment.md.txt)


In this step, you will create an environment and an environment group.


In Apigee, API proxies are deployed to *environments*, which provide isolated contexts for your
proxies. Environments are organized into *environment groups*, which provide hostnames for all
the proxies deployed to environments within the group. You must have at least one environment and
at least one environment group. To learn more, see [About environments and environment groups](https://docs.cloud.google.com/apigee/docs/api-platform/fundamentals/environments-overview.md.txt).

## Create an environment


Create the environment first before creating the environment group. You can create an environment
using the Apigee hybrid UI or using the CLI. You may want to use the UI for these steps to
familiarize yourself with it.

### Apigee hybrid UI

To access the hybrid UI and add an environment, perform the following steps:

1. Open the [Apigee UI](https://apigee.google.com). If this is the first time you are logging in, hybrid displays a consent dialog. If you are prompted to select from more than one account, choose the account that owns the project you created in [Step 2: Create a Google Cloud project](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/precog-gcpproject.md.txt). Then click **Allow**.
2. Your browser navigates to the hybrid UI main landing page:
3. ![The landing page in the Apigee
   hybrid UI, which consists of left-hand navigation and large images that are links.](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/ui-landing.png "Apigee landing page")
4.
   Ensure that your hybrid-enabled organization is selected from the organization drop-down list.
   If it is not selected, select it from the drop-down list, as the following example shows:

   ![A list of organizations that are hybrid enabled](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/ui-project-selector.png "Hybrid-enabled organizations")

   > [!NOTE]
   > **Note:** When you select a hybrid-enabled organization from the drop-down list, the hybrid UI displays the Apigee organization name and the Google Cloud project name in the header. The Apigee organization name and Google Cloud project name are the same.

5. Click **Admin \> Environments \> Overview** .

   ![The Apigee hybrid UI menu showing Admin, Environments, Overview expanded](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/hybrid-ui-menu-admin-environments-overview.png "Admin, Environments, Overview option")

   The **Environments** view is displayed, with no environments (yet):

   ![The Environments view, which is blank (no environments)](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/ui-no-environments.png "Environments")
6. Click **+Environment** .

   The **New environment** dialog is displayed:

   ![The new environment dialog](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/ui-new-environment.png "New Environment")
7. Enter the following information in the **New Environment** dialog:
   1. **Display name** **(Required)** : A friendly name for the environment that is used in the UI. For example, "My First Environment" or "test". Unlike the **Environment
      name** , the **Display name** can include uppercase and other special characters.
   2. **Environment name** **(Required)** : The programmatic name for the environment; also known as the *environment ID* .

      For example, "my-environment" or "test".

      > [!CAUTION]
      > **Caution:** An environment name can contain only lowercase letters, numbers, and hyphens. You cannot use uppercase letters or any other special characters. In addition, the **Environment name** can be up to a maximum of 32 characters long. For example: `my-test-env` or `my-test-env-42`.

      The **Display name** and the **Environment name** can be
      different.
   3. **Description** (*Optional*): Additional information about the environment that you want to add as a reminder of the purpose of the environment. For example, "Created during initial installation".
8. Click **Create** .

   Apigee creates the new environment and indicates that it is **Pending Provisioning**:
   ![Pending Provisioning status
   message](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/ui-myenv-pending.png "Pending Provisioning")

   In a few moments, it changes to *provisioned*:

   ![New
   environment was provisioned message](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/ui-myenv-provisioned.png "Environment created")

   However, you're not quite done. You also need to add your new environment to the
   runtime's `overrides.yaml` file---but first you've got to install the runtime,
   so let's not get ahead of ourselves.

### gcloud CLI


To create an environment with the
[Create
environments API](https://docs.cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments), perform the following steps:

1. Open a terminal on the device you are using to manage Apigee.
2. On the command line, get your `gcloud` authentication
   credentials using the following command:

   ### Linux / MacOS

   ```
   TOKEN=$(gcloud auth print-access-token)
   ```

   To check that your token was populated, use `echo`, as the
   following example shows:

   ```
   echo $TOKEN
   ```

   This should display your token as an encoded string.

   ### Windows

   ```
   for /f "tokens=*" %a in ('gcloud auth print-access-token') do set TOKEN=%a
   ```

   To check that your token was populated, use `echo`, as the
   following example shows:

   ```
   echo %TOKEN%
   ```

   This should display your token as an encoded string.
3. Create environment variables for the elements of the environment. You will use the following variable in the command to create it:
   - **`ENV_NAME`** **(Required)** is the programmatic ID for your environment. The environment name can contain lowercase letters, dashes, and numbers and must start with a lowercase letter. This name will be used as the identifier and cannot be changed after creation

     ```
     export ENV_NAME=environment_name
     ```
   - **`ENV_DISPLAY_NAME`** **(Required)** is the user-friendly name of your environment. This value does not need to be unique, and can include spaces and special characters. For example, "My Example Environment".

     ```
     ENV_DISPLAY_NAME=friendly_name
     ```
   - **`ORG_NAME`** **(Required)** is your organization ID. Make sure you have defined the `ORG_NAME` environment variable from [Step 4: Create an organization](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/precog-provision.md.txt):

     ```
     echo $ORG_NAME
     ```
   - **`ENV_DESCRIPTION`** *(Optional)* is information about the environment that you'd like to use as a reminder of its purpose. For example, "Example environment for Apigee Hybrid instructions".

     ```
     ENV_DESCRIPTION=description_text
     ```
4. Send an authenticated `POST` request to the Create environments API.

   > [!NOTE]
   > **Note:** After you create a hybrid-enabled organization, you cannot delete the organization, change the organization ID, or change the Google Cloud project that is bound to your organization. To change any of these things, contact [Google Cloud Customer Care](https://cloud.google.com/support-hub/).

   The following example shows the request structure that creates an environment, using the following command:

   ```
   curl -H "Authorization: Bearer $TOKEN" -X POST -H "content-type:application/json"   -d '{
       "name": "'"$ENV_NAME"'",
       "displayName": "'"$ENV_DISPLAY_NAME"'",
       "description": "'"$ENV_DESCRIPTION"'"
     }'   "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/environments"
   ```

   On a successful creation request, the Environments API should respond with a message similar
   to the following:

   ```
   {
     "name": "organizations/hybrid-example/operations/c2aee040-7e79-4fd4-b0cf-79ca1b7098a8",
     "metadata": {
       "@type": "type.googleapis.com/google.cloud.apigee.v1.OperationMetadata",
       "operationType": "INSERT",
       "targetResourceName": "organizations/hybrid-example/environments/example-env",
       "state": "IN_PROGRESS"
     }
   }
   ```

   As the `state` property in the response indicates, Apigee has started to create
   the new environment, so its state is `IN_PROGRESS`. This process can take several
   minutes.

## Create an environment group


Now create an environment group and assign the environment you just created to it.
Environment groups allow you to group environments together, and provide the hostnames for
routing the proxies deployed to the environments within the group. You must create at least
one environment group, and you must assign at least one hostname to the group. For an overview
of environment groups, see [About environments and environment groups](https://docs.cloud.google.com/apigee/docs/api-platform/fundamentals/environments-overview.md.txt).

> [!NOTE]
> **Note:**Every environment group you create with an attached environment must be included in all override files where the environment is used.

### Apigee hybrid UI


To create an environment group using the Apigee UI, perform the following steps:

1. Open the [Apigee UI](https://apigee.google.com).
2. Your browser navigates to the hybrid UI main landing page.
3. Ensure that your hybrid-enabled organization is selected from the organization drop-down list. If it is not selected, select it from the drop-down list.
4. Click **Admin \> Environments \> Groups** .


   The **Environment Groups Overview** view is displayed, with any created environment groups:


   ![The Environment groups view, showing any created groups](https://docs.cloud.google.com/static/apigee/docs/images/ui-environment-groups.png "Environment groups")
5. Click **+Environment Group** .


   The **Add an Environment Group** dialog is displayed.


   ![Add Environment Group dialog showing blank Name field](https://docs.cloud.google.com/static/apigee/docs/images/ui-add-environment-group.png "Add environment group")
6. Enter a name and then click **Add**.
7.
   Hold the pointer over the newly-created environment group and then click
   **Edit** .


   Add a hostname that all proxies deployed to environments within this group will use. This
   should be a domain you have management access to. The hostname can be the domain itself,
   like `example.com` or it can include a subdomain like
   `my-proxies.example.com`.


   If you need to register a domain, see a domain registrar like
   [Google Domains](https://domains.google).
8. ![Edit Environment Group window showing no environments assigned](https://docs.cloud.google.com/static/apigee/docs/hybrid/v1.6/images/ui-edit-environment-group.png "Edit environment group")
9. Click **Add (+)**.
10. The **Add environment** dialog displays.
11. ![Add environment dialog listing available environments](https://docs.cloud.google.com/static/apigee/docs/images/ui-add-environment.png "Add environment")
12. Select an environment from the list and then click **Add**.

### gcloud CLI


To create an environment group using the command line, perform the following steps:

1. On the command line, get your `gcloud` authentication
   credentials using the following command:

   ### Linux / MacOS

   ```
   TOKEN=$(gcloud auth print-access-token)
   ```

   ### Windows

   ```
   for /f "tokens=*" %a in ('gcloud auth print-access-token') do set TOKEN=%a
   ```
2. Make sure you have the **DOMAIN** environment variable set as the following example shows:

   ```
   echo $DOMAIN
   ```


   This is the hostname that all proxies deployed to environments within this group will
   use. This should be a domain you have management access to. The hostname can be the domain
   itself, like `example.com` or it can include a subdomain like
   `my-proxies.example.com`.


   If it is not set, create it with the domain you plan to use for your Apigee hybrid installation.
   For example:

   ```
   export DOMAIN=domain-name.com
   ```
3. Make sure you have the **ENV_NAME** environment variable set to the environment you just created in the previous steps. For example:

   ```
   echo $ENV_NAME
   ```
4. Create an environment variable for your intended environment group name. For example:

   ```
   export ENV_GROUP=environment-group-name
   ```
5. Create the environment group with the following command:

   ```
   curl -H "Authorization: Bearer $TOKEN" -X POST -H "content-type:application/json" \
      -d '{
        "name": "'"$ENV_GROUP"'",
        "hostnames":["'"$DOMAIN"'"]
      }' \
      "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups"
       
   ```
6. Assign the environment to the new group with the following command:

   ```
   curl -H "Authorization: Bearer $TOKEN" -X POST -H "content-type:application/json" \
      -d '{
        "environment": "'"$ENV_NAME"'",
      }' \
      "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups/$ENV_GROUP/attachments"
       
   ```

> [!NOTE]
> **Congratulations!**
>
> Now that you've created a Google Cloud account and project, provisioned an org, enabled the
> necessary APIs, and created a new environment and environment group, you're ready
> to install and set up the Apigee hybrid runtime.

## Next step

To continue with the installation, see
[Runtime installation: Before you begin](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/install-before-begin.md.txt).