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.
Create an environment
Create the environment first before creating the environment group. You can create an environment using the Apigee UI or using the API. You may want to use the UI for these steps to familiarize yourself with it.
Apigee UI
To access the UI and add an environment, perform the following steps:
- Open the Apigee UI. 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 Google Cloud project you are using to install Apigee hybrid. Then click Allow.
-
Ensure that your 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:
- Click Admin > Environments > Overview.
The Environments view is displayed, with no environments (yet):
- Click +Environment.
The New environment dialog is displayed:
- Enter the following information in the New Environment dialog:
- 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.
- Environment name (Required): The programmatic name for the environment; also known
as the environment ID.
For example, "my-environment" or "test".
The Display name and the Environment name can be different.
- 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".
- Keep any other defaults and click Create.
Apigee creates the new environment.
You now need to create an environment group and add your new environment to the group.
Your browser navigates to the UI main landing page:
Apigee API
To create an environment with the Create environments API, perform the following steps:
- Open a terminal on the device you are using to manage Apigee.
-
On the command line, get your
gcloud
authentication credentials using the following command:Linux / MacOS
export 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.
- Create the following environment variable:
Linux / MacOS
export ENV_NAME="YOUR_ENV_NAME"
Windows
set ENV_NAME="YOUR_ENV_NAME"
Where:
-
ENV_NAME
(Required) 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 of the environment.
-
- Call the following Apigee API:
curl -H "Authorization: Bearer $TOKEN" -X POST -H "content-type:application/json" -d '{ "name": "'"$ENV_NAME"'" }' "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 isIN_PROGRESS
. - Check to verify the environment was created successfully:
curl -H "Authorization: Bearer $TOKEN" \ "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/environments"
On a successful creation request, the Environments API responds with a message similar to the following:
[ "your-environment-name" ]
Create an environment group
Now create an environment group and assign the environment you just created to it.
Apigee UI
To create an environment group using the Apigee UI, perform the following steps:
- Open the Apigee UI.
- Ensure that your organization is selected from the organization drop-down list. If it is not selected, select it from the drop-down list.
-
Click Admin > Environments > Groups.
The Environment Groups Overview view is displayed:
-
Click +Environment Group.
The Add an Environment Group dialog is displayed.
- Enter a name and then click Add.
-
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 likemy-proxies.example.com
.If you need to register a domain, see a domain registrar like Google Domains.
- Click Add (+) in the Environments box.
-
The Add environment dialog displays.
- Select an environment from the list and then click Add.
- Click Save.
Your browser navigates to the Apigee UI main landing page.
Apigee API
To create an environment group using the Apigee API:
-
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
- Create the following environment variables:
Linux / MacOS
export DOMAIN="YOUR_DOMAIN"
export ENV_GROUP="YOUR_ENVIRONMENT_GROUP"
Windows
data-terminal-prefix=">">set ENV_GROUP="YOUR_ENVIRONMENT_GROUP"
data-terminal-prefix=">">set DOMAIN="YOUR_DOMAIN"
Where:
DOMAIN
(Required) This is the hostname that all proxies deployed to environments within this group will use. This should be a domain you manage. The address can be the domain itself, likeexample.com
or it can include a subdomain likemy-proxies.example.com
. If you don't have a managed domain, you can enter a placeholder for now. You can change the domain address later.-
ENV_GROUP
(Required) 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.
- Create the environment group:
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"
- Assign the environment to the new group:
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"
- Verify whether the environment group was created successfully with the following CURL command:
curl -H "Authorization: Bearer $TOKEN" \ "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups"
On a successful creation request, the Environments Group API responds with a message similar to the following:
{ "environmentGroups": [ { "name": "your_envgroup_hybrid", "hostnames": [ "apigee.hybrid.com" ], "createdAt": "1677826235324", "lastModifiedAt": "1677826235324", "state": "ACTIVE" } ] }
- Fetch the latest attachments for the newly created environment group by using following CURL command:
curl -H "Authorization: Bearer $TOKEN" \ "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups/$ENV_GROUP/attachments"
The environment group creation and attachment were successful if the result shows a unique hash value, as shown in the below sample response output:
{ "environmentGroupAttachments": [ { "name": "c27046d1-b83e-4cba-xxxx-caaa660b2bd6", "environment": "your_envtest_hybrid", "createdAt": "1677826263567", "environmentGroupId": "your_envgroup_hybrid" } ] }
Next step
To continue with the installation, go to Part 2: Hybrid runtime setup.