Step 1: Define environment variables

You're viewing Apigee X documentation.
View Apigee Edge documentation.

What you're doing in this step

This section describes how to set several environment variables that are used throughout the documentation (and especially in this configuration tutorial). Google strongly recommends that you use them so that you can enter the commands as shown.

Perform the step

To define environment variables on the command line:

  1. Log in to Cloud by using the following command:
    gcloud auth login

    The command launches a browser window and prompts you to choose an account (if you have more than one). Cloud then prompts you to allow access. You only need to do this once: You will not need to run this command, choose an account, or allow access in the future.

  2. Initialize the Cloud SDK, as described in Initializing Cloud SDK; for example:
    gcloud init

    During SDK initialization, enter or select the ID of the project you created in Prerequisites. Set this project as the default. You will not need to run this command in the future unless you want to change the defaults.

  3. Define the following environment variables for the current project:
    AUTH="Authorization: Bearer $(gcloud auth print-access-token)"
    PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)")


    • AUTH defines the Authentication header with a bearer token. You will use this header when you send HTTP requests to your API proxy.
    • PROJECT_ID is the Cloud project ID that you created as part of the Prerequisites. If you're not sure what your project ID is, use Cloud Console or the gcloud projects list command to find it.
    • PROJECT_NUMBER is the Cloud project number that you created as part of the Prerequisites. This example issues a gcloud command to get the project number for you. Alternatively, you can use the gcloud projects list command to find it.
    • RUNTIME_LOCATION is the physical location where your instance is located. Valid values are any Compute Engine region (for paid orgs) or Compute Engine zone (for eval orgs). For more information, see Compute Engine locations.

    • ANALYTICS_REGION is the physical location at which you store your analytics data.

      Valid values are a subset of the Compute Engine regions. Possible values are:

      • asia-northeast1
      • asia-south1
      • europe-west1
      • us-central1
      • us-east1
      • us-west1
      • australia-southeast1
      • europe-west2

      Both eval and paid accounts use regions for the analytics location. Therefor, for paid orgs its value can be the same as the RUNTIME_LOCATION (also a region). But the value of ANALYTICS_REGION does not have to be the same as RUNTIME_LOCATION. However, there may be a performance benefit if they are the same.

      For eval accounts, the analytics location is a region but the runtime location is a zone, so they will not be the same.

    The following example defines environment variables for a paid org:

    AUTH="Authorization: Bearer $(gcloud auth print-access-token)"

    If this were for an eval org, the RUNTIME_LOCATION would be set to a zone instead of a region.

    You will use the variable names, such as $PROJECT_ID as string literals in your commands.

    Note that you might not use all of these environment variables during your provisioning and configuration.

  4. (Optional) Check your work by echoing the values you just set. Note that when you want to use a variable in your commands, precede the variable's name with a dollar sign ($).

    The responses to your echo commands should look like the following:

    echo $AUTH
    Authorization: Bearer ya29.a123456678940B63hPSAMPLEsampleKKYVsample0f3pWDWZDuH2-hENkNaTvgZ1PD977TMvv6edBQPJezdHw040880Ol_LoD5ZDkt-i-knizia_KhA9L20sSvztL81-SAMPLE42ELPMASk2_1CxN
    echo $PROJECT_ID

If you encounter errors during this part of the process, see Troubleshooting.

1 NEXT: Enable APIs 3 4 5 6 7 8