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

Basic Syntax

Updated on 2023-12-13 GMT+08:00

The RFS configuration language is easy, highly readable, and compatible with the HCL and JSON syntax. This section describes the basic syntax and common functions of the HCL.

The RFS configuration language consists of arguments, blocks, expressions, and functions.

Arguments

Use an equal sign (=) to assign a value or expression to a particular name, which can contain letters, digits, underscores (_), and hyphens (-), but cannot start with a digit. For example:

image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"

Blocks

Aggregate multiple arguments and can contain another blocks. A block consists of type, label, and body. The format is as follows:
resource "myinstance" {
   name   = "myinstance"
    ......
    network {
        uuid = "55534eaa-533a-419d-9b40-ec427ea7195a"
    }
}

Before using a block, you must declare its type (resource and network in this example), where resource is the top-level block type and network is the nested block type. The top-level block type keywords supported by the HCL include provider, resource, data, variable, output, module, and locals.

Block labels are defined after the block type, and the number of block labels is determined by the block type. In the example, the resource block type expects : myinstance. The nested network type does not have block labels. The block body is defined at the last and delimited by the { and } characters. Other types can be nested in the block body to implement different layered structures.

Argument Types

The HCL supports the following argument types:

Basic types

  • string: consists of one or more Unicode characters, for example, hello.
  • number: can be an integer or a floating point number.
  • bool: can only be true or false.

The HCL can automatically convert the number and bool types to the string type based on the argument type. If a string can be represented as a value of the number or bool type, it can also be converted to the other two types. Arguments of the three types can be directly assigned values. For example:

disk_type = "SSD"
disk_size = 40
enable    = true

# Strings can be of the number and bool types.
disk_size = "40"
enable    = "true"

Set types

  • map(...): a set of data elements combined using key-value pairs. The key is of the string type, while the value can be of the string, number, or bool type. The values of all elements must be of the same type.
  • list(...): a set of data elements of the same type. The elements can be of the basic type or block type. The list index starts from 0.
  • set(...): similar to the list type. Elements in a set are unique and do not have any auxiliary identifier or sequence.
The map type is delimited in { and } and has flexible types. Key-value pairs can be connected using equal signs (=) or colons (:). If a key does not start with a digit, double quotation marks (") are not required. For multi-line mapping, key-value pairs can be separated by newline characters or commas (,). You are advised to use equal signs (=) to connect key-value pairs and separate them with newline characters. For example:
# Recommended format
tags = {
  foo = "bar"
  key = "value"
}

# Other formats
tags = {"foo" = "bar", "key" = "value"}
tags = {"foo" : "bar", "key" : "value"}
tags = {foo = "bar", key = "value"}
tags = {foo : "bar", key : "value"}
tags = {
  foo : "bar"
  key : "value"
}

The list type and set type are represented in the same way. The list/set whose elements are of the basic type is delimited using [ and ], and the list/set whose elements are of the block type is represented in the form of repeated blocks. For example:

# List whose elements are of the basic type
security_groups = ["default", "internal"]

# List whose elements are of the block type
network {
  uuid = "55534eaa-533a-419d-9b40-ec427ea7195a"
}
network {
  uuid = "ad091b52-742f-469e-8f3c-fd81cadf0743"
}

Special types

  • null: If a parameter is set to null, the parameter has no specified value. The HCL automatically ignores the parameter and uses the default value. Null is common in conditional expressions, for example, var.test==""? null: var.test, indicating that when the value of var.test is "", it is ignored.

Other Syntax

  • A single-line comment starts with # or //.
  • /* and */ are start and end delimiters for a comment that might span over multiple lines. Nested block comments are not supported.
  • Terraform configuration files are UTF-8 encoded. Terraform accepts non-ASCII characters in identifiers, comments, and string values.
  • A multi-line string starts with <<EOF, contains the string content in the middle, and ends with EOF. EOF can also be replaced with other characters. For example:
      ...
      website {
        ...
        routing_rules = <<EOF
    [{
        "Condition": {
            "KeyPrefixEquals": "docs/"
        },
        "Redirect": {
            "ReplaceKeyPrefixWith": "documents/"
        }
    }]
    EOF
      }
    }

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