Help Center/ Terraform/ User Guide/ HUAWEI CLOUD Provider Authentication
Updated on 2023-12-22 GMT+08:00

HUAWEI CLOUD Provider Authentication

HUAWEI CLOUD Provider uses AK/SK for authentication. You can provide credentials as either static credentials or environment variables.

Static Credentials

Configure parameters region, access_key, and secret_key in the provider block. For example:

provider "huaweicloud" {
  region     = "cn-north-1"
  access_key = "my-access-key"
  secret_key = "my-secret-key"
}

Static credentials are simple to use. However, they require AKs and SKs to be stored in configuration files in plaintext, which risks secret leakage. It is recommended that you provide credentials as environment variables.

Environment Variables

Configure the region, AK, and SK as environment variables. For example:

$ export HW_REGION_NAME="cn-north-1"
$ export HW_ACCESS_KEY="my-access-key"
$ export HW_SECRET_KEY="my-secret-key"

After setting the environment variables, declare the HUAWEI CLOUD provider.

provider "huaweicloud" {}

Parameter Description

Table 1 Provider authentication parameters

Parameter

Mandatory

Environment Variable

Description

region

Yes

HW_REGION_NAME

Region where the HUAWEI CLOUD service is located. For details, see Regions and Endpoints.

If you want to create cloud services in different regions, configure parameter alias or region for the resource corresponding to the cloud service.

access_key

Yes

HW_ACCESS_KEY

Access key ID of a user. For details on how to obtain an access key ID, see Access Keys.

secret_key

Yes

HW_SECRET_KEY

Secret access key of a user. For details on how to obtain a secret access key, see Access Keys.

domain_name

No

HW_DOMAIN_NAME

HUAWEI CLOUD account name. For details on how to obtain an account name, see API Credentials.

project_name

No

HW_PROJECT_NAME

HUAWEI CLOUD project name. For details on how to obtain a project name, see API Credentials.

enterprise_project_id

No

HW_ENTERPRISE_PROJECT_ID

Enterprise project ID. For more information about enterprise projects and how to obtain enterprise project IDs, see Enterprise Management User Guide.

max_retries

No

HW_MAX_RETRIES

Maximum number of retries allowed when a network transmission problem occurs. The default value is 5.