Deploy Turbo File System
Application Scenario
Huawei Cloud Scalable File Service (SFS Turbo) file system functionality provides high-performance, highly available file storage services, specifically designed for high-performance computing (HPC), AI/ML workloads, and large-scale data processing scenarios. SFS Turbo supports NFS and CIFS protocols, providing high IOPS, low-latency file access capabilities, meeting the storage requirements of enterprise applications.
This best practice is particularly suitable for scenarios that require high-performance file storage, support large-scale concurrent access, implement data sharing and collaboration, such as HPC clusters, machine learning training, big data analysis, containerized application storage, etc. This best practice will introduce how to use Terraform to automatically deploy SFS Turbo file systems, including VPC network, security group, and SFS Turbo file system creation, implementing a complete file storage solution.
Related Resources/Data Sources
This best practice involves the following main resources and data sources:
Data Sources
Resources
Resource/Data Source Dependencies
Operation Steps
1. Script Preparation
Prepare the TF file (e.g., main.tf) in the specified workspace for writing the current best practice script, ensuring that it (or other TF files in the same directory) contains the provider version declaration and Huawei Cloud authentication information required for deploying resources. Refer to the "Preparation Before Deploying Huawei Cloud Resources" document for configuration introduction.
2. Query Availability Zone Information
Add the following script to the TF file (e.g., main.tf) to instruct Terraform to query availability zone information:
Parameter Description:
This data source requires no additional parameters and automatically queries all availability zones in the current region
3. Create VPC Network
Add the following script to the TF file to instruct Terraform to create a VPC resource:
Parameter Description:
name: VPC name, assigned by referencing the input variable vpc_name
cidr: VPC CIDR block, assigned by referencing the input variable vpc_cidr, default value is "192.168.0.0/16"
4. Create VPC Subnet
Add the following script to the TF file to instruct Terraform to create a VPC subnet resource:
Parameter Description:
vpc_id: VPC ID that the subnet belongs to, referencing the ID of the previously created VPC resource
name: Subnet name, assigned by referencing the input variable subnet_name
cidr: Subnet CIDR block, automatically calculated if subnet_cidr is empty, otherwise uses subnet_cidr value
gateway_ip: Subnet gateway IP, automatically calculated if subnet_gateway_ip is empty, otherwise uses subnet_gateway_ip value
5. Create Security Group
Add the following script to the TF file to instruct Terraform to create a security group resource:
Parameter Description:
name: Security group name, assigned by referencing the input variable security_group_name
delete_default_rules: Whether to delete default rules, set to true to delete default security group rules
6. Create SFS Turbo File System
Add the following script to the TF file to instruct Terraform to create an SFS Turbo file system resource:
Parameter Description:
vpc_id: VPC ID, referencing the ID of the previously created VPC resource
subnet_id: Subnet ID, referencing the ID of the previously created VPC subnet resource
security_group_id: Security group ID, referencing the ID of the previously created security group resource
availability_zone: Availability zone, using the first queried availability zone
name: SFS Turbo file system name, assigned by referencing the input variable turbo_name, default value is empty string
size: File system capacity, assigned by referencing the input variable turbo_size, default value is 1228 (GB)
share_proto: Sharing protocol, assigned by referencing the input variable turbo_share_proto, default value is "NFS"
share_type: Sharing type, assigned by referencing the input variable turbo_share_type, default value is "STANDARD"
hpc_bandwidth: HPC bandwidth specification, assigned by referencing the input variable turbo_hpc_bandwidth, default value is empty string
tags: File system tags, assigned by referencing the input variable turbo_tags, default value is empty map
backup_id: Backup ID, assigned by referencing the input variable turbo_backup_id, default value is empty string
enterprise_project_id: Enterprise project ID, assigned by referencing the input variable enterprise_project_id, default value is null
charging_mode: Billing mode, assigned by referencing the input variable charging_mode, default value is "postPaid"
period_unit: Billing period unit, assigned by referencing the input variable period_unit, default value is null
period: Billing period, assigned by referencing the input variable period, default value is null
auto_renew: Whether to auto-renew, assigned by referencing the input variable auto_renew, default value is "false"
lifecycle.ignore_changes: Lifecycle management, ignores changes to availability_zone
7. Preset Input Parameters Required for Resource Deployment (Optional)
In this practice, some resources and data sources use input variables to assign values to configuration content. These input parameters need to be manually entered during subsequent deployments. At the same time, Terraform provides a method to preset these configurations through .tfvars files, which can avoid repeated input during each execution.
Create a terraform.tfvars file in the working directory with the following example content:
Usage:
Save the above content as
terraform.tfvarsfile in the working directory (this file name allows users to automatically import the content of thistfvarsfile when executing terraform commands; for other names,.autoneeds to be added before tfvars, such asvariables.auto.tfvars)Modify parameter values as needed
When executing
terraform planorterraform apply, Terraform will automatically read the variable values from this file
In addition to using terraform.tfvars file, variable values can also be set in the following ways:
Command line parameters:
terraform apply -var="vpc_name=my-vpc" -var="turbo_name=my-turbo"Environment variables:
export TF_VAR_vpc_name=my-vpcCustom named variable files:
terraform apply -var-file="custom.tfvars"
Note: If the same variable is set in multiple ways, Terraform will use the variable value according to the following priority: command line parameters > variable files > environment variables > default values.
8. Initialize and Apply Terraform Configuration
After completing the above script configuration, execute the following steps to create resources:
Run
terraform initto initialize the environmentRun
terraform planto view the resource creation planAfter confirming the resource plan is correct, run
terraform applyto start creating file systemsRun
terraform showto view the created file system details
Reference Information
Last updated