Alibaba Cloud Edge Node Service (ENS) is integrated with Terraform. You can use Terraform to quickly configure ENS. This topic describes how to use Terraform in Cloud Shell to create an ENS instance.
Background information
Terraform is a tool that supports the automated orchestration of IT infrastructure. Terraform allows you to securely and efficiently preview, configure, and manage cloud infrastructure and resources. For more information about Terraform, see What is Terraform?
Cloud Shell in Alibaba Cloud is a free O&M service that comes with Terraform and is configured with authentication credentials. You can run Terraform commands in Cloud Shell.
Procedure
Access Cloud Shell by using a browser.
For more information about how to use Cloud Shell, see Use Cloud Shell.
Create an execution directory and access the directory.
NoteYou need to create an execution directory for each Terraform project.
mkdir /usr/local/terraform cd /usr/local/terraform
Use the
Vim
editor to write the terraform.tf file.vim terraform.tf
The following example shows the content of the terraform.tf file:
NoteFor information about how to configure parameters in the resource block, see alicloud_ens_instance in the Terraform documentation.
resource "alicloud_ens_instance" "instance" { period = 1 data_disk { size = 20 category = "cloud_efficiency" } public_ip_identification = true period_unit = "Month" scheduling_strategy = "Concentrate" schedule_area_level = "Region" image_id = "centos_7_06_64_20G_alibase_20191119" instance_type = "ens.sn1.small" host_name = "Host80" password = "Ex*****6@" internet_charge_type = "BandwidthByDay" payment_type = "PayAsYouGo" internet_max_bandwidth_out = 50 ens_region_id = "cn-zhengzhou-telecom" system_disk { size = 20 } }
Run the
terraform init
command to initialize the Terraform configuration files.Run the
terraform plan
command to preview configurations.Run the
terraform apply
command to create an ENS instance. After you run the terraform apply command, you need to preview the code to ensure that the code is correct and enteryes
to confirm. Then, Terraform starts to apply the configurations, which may require a few minutes.After you run the command successfully, the following output is displayed.
Run the
terraform show
command to view the configuration results.
References
Terraform is supported by mainstream operating systems such as macOS, Windows, and Linux. For information about how to configure Terraform in the local PC, see Install and configure Terraform in the local PC.
For more information about Alibaba Cloud services that are integrated with Terraform, see Alibaba Cloud Provider.