Preparation Before Deploying Huawei Cloud Resources

Before starting to use Terraform, you need to complete the following preparation steps.

Install Terraform

Terraform installation methods vary by operating system. We provide detailed installation guide documentation: How to Install Terraform Please follow the instructions in the documentation.

Prepare Working Directory for Deployment Scripts

Create a new working directory and prepare Terraform configuration files (with .tf extension, such as main.tf):

mkdir -p terraform-demo
cd terraform-demo
touch main.tf

In main.tf, you will define the HCL scripts needed to deploy Huawei Cloud resources.

Configure Huawei Cloud Authentication Information

You can configure Huawei Cloud authentication information by setting the following environment variables:

# Required Configuration
export HW_ACCESS_KEY="your_ak"     # AK, generated in console "My Credentials - Access Keys"
export HW_SECRET_KEY="your_sk"     # SK, generated in console "My Credentials - Access Keys"
export HW_REGION_NAME="cn-north-4" # Region code, e.g.: cn-north-4

# Optional Configuration
export HW_ENTERPRISE_PROJECT_ID="your_eps_id" # Enterprise Project ID (if needed)
export HW_DOMAIN_NAME="your_domain_name"      # Account name (if cross-account operations needed)

Method 2: Provider Configuration Block

Configure authentication information directly in Terraform configuration files:

Reference Information

Last updated