Deploy Global Connection Bandwidth
Application Scenario
Cloud Connect (CC) global connection bandwidth is a global network bandwidth resource provided by the Cloud Connect service, used to provide bandwidth guarantee for network connections across regions and countries. By creating global connection bandwidth, you can uniformly manage and allocate network bandwidth resources globally, achieving flexible network bandwidth configuration and cross-border network connections. Automating global connection bandwidth creation through Terraform can ensure standardized and consistent bandwidth resource management, improving operational efficiency. This best practice will introduce how to use Terraform to automatically create a Cloud Connect global connection bandwidth.
Related Resources/Data Sources
This best practice involves the following main resources:
Resources
Resource/Data Source Dependencies
huaweicloud_cc_global_connection_bandwidthOperation 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. Create Cloud Connect Global Connection Bandwidth Resource
Add the following script to the TF file (e.g., main.tf) to instruct Terraform to create a Cloud Connect global connection bandwidth resource:
Parameter Description:
name: The global connection bandwidth name, assigned by referencing the input variable global_connection_bandwidth_name
type: The global connection bandwidth type, assigned by referencing the input variable bandwidth_type
bordercross: Whether the global connection bandwidth crosses borders, assigned by referencing the input variable bordercross
size: The bandwidth size of the global connection bandwidth, assigned by referencing the input variable bandwidth_size
charge_mode: The billing option of the global connection bandwidth, assigned by referencing the input variable charge_mode
description: The description of the global connection bandwidth, assigned by referencing the input variable global_connection_bandwidth_description, default value is "Created by Terraform"
tags: The tags of the global connection bandwidth, assigned by referencing the input variable global_connection_bandwidth_tags, default value includes "Owner" and "Env" tags
3. Preset Input Parameters Required for Resource Deployment (Optional)
In this practice, the resource uses input variables to assign configuration content. These input parameters need to be manually entered during subsequent deployment. 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 a
terraform.tfvarsfile in the working directory (this filename allows users to automatically import the content of thistfvarsfile when executing terraform commands. For other naming, you need to add.autobefore tfvars, such asvariables.auto.tfvars)Modify parameter values according to actual needs
When executing
terraform planorterraform apply, Terraform will automatically read the variable values in this file
In addition to using the terraform.tfvars file, you can also set variable values in the following ways:
Command line parameters:
terraform apply -var="global_connection_bandwidth_name=test-bandwidth" -var="bandwidth_size=10"Environment variables:
export TF_VAR_global_connection_bandwidth_name=test-bandwidthandexport TF_VAR_bandwidth_size=10Custom named variable file:
terraform apply -var-file="custom.tfvars"
Note: If the same variable is set through multiple methods, Terraform will use variable values according to the following priority: command line parameters > variable file > environment variables > default values.
4. Initialize and Apply Terraform Configuration
After completing the above script configuration, execute the following steps to create a Cloud Connect global connection bandwidth:
Run
terraform initto initialize the environmentRun
terraform planto view the resource creation planAfter confirming that the resource plan is correct, run
terraform applyto start creating the Cloud Connect global connection bandwidthRun
terraform showto view the details of the created Cloud Connect global connection bandwidth
Reference Information
Last updated