Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ API Gateway/ User Guide/ Shared Gateway (for Existing Users)/ Environment Management/ Creating an Environment and Environment Variable

Creating an Environment and Environment Variable

Updated on 2024-04-03 GMT+08:00

Scenario

An API can be called in different environments, such as production, testing, and development environments. RELEASE is the default environment provided by APIG. You can define environment variables to allow an API to be called in different environments.

Environment variables are manageable and specific to environments. You can create variables in different environments to call different backend services using the same API.

For variables you define during API creation, you must create corresponding variables and values. For example, variable Path is defined for an API, and two variables with the same name are created and assigned values /Stage/test and /Stage/AA in environments 1 and 2, respectively. If the API is published and called in environment 1, the path /Stage/test is used. If the API is published and called in environment 2, the path /Stage/AA is used.

Figure 1 Environment variables
NOTE:

You can create a maximum of 50 variables for an API group in each environment.

Prerequisites

You have created an API group.

Creating an Environment

  1. Access the shared gateway console.
  2. In the navigation pane, choose API Publishing > Environments.
  3. Click Create Environment, and set the parameters listed in Table 1.

    Figure 2 Creating an environment
    Table 1 Environment information

    Parameter

    Description

    Name

    Environment name.

    Description

    Description of the environment.

  4. Click OK.

    After the environment is created, it is displayed in the environment list.

Accessing an Environment

You can call an API in the RELEASE environment by using a RESTful API. To access the API in other environments, add the X-Stage header to the request to specify an environment name. For example, add X-Stage:DEVELOP to the request header to access an API in the DEVELOP environment.

NOTE:

APIG does not support API debugging using environment variables.

Creating an Environment Variable

  1. In the navigation pane, choose API Publishing > API Groups.
  2. Create a variable. You can use one of the following methods:

    • Click the name of the target API group, and click the Variables tab on the displayed API group details page.
    • In the Operation column of the target API group, choose More > Manage Variable.

  3. Select an environment from the Environment drop-down list, and click Create Variable.
  4. Set the parameters listed in Table 2.

    Figure 3 Creating an environment variable
    Table 2 Parameters for creating an environment variable

    Parameter

    Description

    Name

    Name of the variable you want to create. Ensure that the name is the same as the name of the variable defined for the API.

    Value

    The path to be used in the selected environment.

  5. Click OK.

    NOTE:

    If a variable is not needed, click Delete in the row containing the variable to delete it.

    Environment variable names and values will be displayed in plain text in API requests. Do not include sensitive information in the variable names and values.

Follow-Up Operations

After creating an environment and variable, publish APIs in the environment so that they can be called by API callers.

Creating an Environment and Environment Variable by Calling an API

You can also create an environment and environment variable by calling an API provided by APIG. For details, see the following references:

Creating an Environment

Creating an Environment Variable

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback