All Products
Search
Document Center

ENS:Use Terraform in Cloud Shell to create an ENS instance

Last Updated:Jun 05, 2024

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

  1. Access Cloud Shell by using a browser.

    For more information about how to use Cloud Shell, see Use Cloud Shell.

  2. Create an execution directory and access the directory.

    Note

    You need to create an execution directory for each Terraform project.

    mkdir /usr/local/terraform
    cd /usr/local/terraform
  3. Use the Vim editor to write the terraform.tf file.

    vim terraform.tf

    The following example shows the content of the terraform.tf file:

    Note

    For 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
      }
    }
  4. Run the terraform init command to initialize the Terraform configuration files.

  5. Run the terraform plan command to preview configurations.

  6. 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 enter yes 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.

    image

  7. Run the terraform show command to view the configuration results.

    image

References