TerraformPilot

DevOps

Terraform for HarmonyOS and OpenHarmony App Backends

Provision HarmonyOS and OpenHarmony app backends with Terraform: Huawei Cloud (HCSO), Volcengine, and self-hosted alternatives for global reach.

LLuca Berton1 min read

HarmonyOS (Huawei) and OpenHarmony (open-source fork stewarded by OpenAtom) are dominant in China and growing globally. Backends usually run on Huawei Cloud (the official huaweicloud Terraform provider exists) for Mainland reach, with mirrored deployments on AWS / Aliyun / Volcengine for SE Asia.

Huawei Cloud Provider

#
terraform {
  required_providers {
    huaweicloud = {
      source  = "huaweicloud/huaweicloud"
      version = "~> 1.70"
    }
  }
}
 
provider "huaweicloud" {
  region     = "cn-north-4"
  access_key = var.hc_access_key
  secret_key = var.hc_secret_key
}

ECS + Cloud Container Engine

#
resource "huaweicloud_cce_cluster" "harmony" {
  name                   = "harmony-prod"
  flavor_id              = "cce.s2.small"
  vpc_id                 = huaweicloud_vpc.this.id
  subnet_id              = huaweicloud_vpc_subnet.this.id
  cluster_version        = "v1.30"
  container_network_type = "vpc-router"
}

Push Service via HMS Push Bridge

#

HMS Push isn't directly Terraform-managed; provision the credential vault and bridge function:

resource "huaweicloud_kms_key" "hms" {
  key_alias = "hms-push-key"
  pending_days = "7"
}
 
resource "huaweicloud_fgs_function" "push_bridge" {
  name        = "hms-push-bridge"
  app         = "default"
  handler     = "index.handler"
  memory_size = 256
  timeout     = 30
  runtime     = "Node.js20.10"
  agency      = huaweicloud_identity_agency.fgs.name
 
  encrypted_user_data = jsonencode({
    HMS_APP_ID = var.hms_app_id
    HMS_SECRET = var.hms_secret
  })
}

Best Practices

#
  • Mainland China requires ICP filing for any public-facing domain — Terraform doesn't file ICP.
  • Mirror critical data to AWS or Volcengine for SE Asia / global users.
  • Use Huawei Cloud KMS for encryption keys — cross-border key transfer is regulated.
  • OpenHarmony and HarmonyOS share APIs but signing certs differ — track per-distribution.
#
#Terraform#HarmonyOS#OpenHarmony#Huawei Cloud#China

Share this article