All Products
Search
Document Center

:Use Terraform in Terraform Explorer

更新時間:Dec 05, 2024

This topic provides an example on how to use Terraform in Terraform Explorer to create a virtual private cloud (VPC).

Terraform Explorer is a tool provided by Alibaba Cloud to debug Terraform configuration files online based on open source Terraform. Terraform Explorer is designed to help developers simplify the processes of writing Terraform configuration files and operating Terraform and lower the barrier to entry for using Terraform. With Terraform Explorer, developers can write a form to automatically generate and convert Terraform configuration files, and use a simple button-based interface to run Terraform online. For more information about Terraform Explorer, see Terraform Explorer introduction.

Terraform Explorer allows you to create resources by configuring custom parameters or by using a sample template. You can use one of the methods to create resources based on your business requirements.

Create a resource by configuring custom parameters

You can create an Alibaba Cloud resource by configuring custom parameters based on your business requirements.

  1. On the Terraform Explorer page of OpenAPI Explorer, configure the Products and Resource Type parameters, configure the parameters in the Parameters section based on the instructions on the Documentation tab on the right, and then click Initiate Debugging.

    For more information about the parameters for creating a VPC, see alicloud_vpc.

    Parameter

    Description

    Example

    vpc_name

    The name of the VPC.

    tf-test-vpc

    cidr_block

    The private CIDR block of the VPC.

    192.168.0.0/16

    description

    The description of the VPC.

    The VPC was created using Terraform.

    image

  2. On the Debugging Code tab, verify the input parameters and click Plan to view the execution plan generated by Terraform.

    image

  3. On the Plan Details tab, view the details of the resource that you want to create. Confirm the information and click Apply.

    image

  4. On the Apply Details tab, view the execution result. If the execution is successful, the following message appears: Apply complete! Resources: 1 added, 0 changed, 0 destroyed. If the execution fails, modify the parameters as prompted and click Save and Continue.

    image

  5. On the Resource Details tab, view the information about the created resource.

    image

  6. If you want to modify the information about the created resource, modify related parameters and click Save and Continue. Then, repeat the operations in Step 2, Step 3, and Step 4. On the Apply Details tab, view the execution result. If the execution is successful, the following message appears: Apply complete! Resources: 0 added, 1 changed, 0 destroyed. If the execution fails, modify the parameters as prompted and click Save and Continue.

    image

  7. If you want to release the created resource, click Destroy Resources on the Apply Details tab. Then, click Apply on the Plan Details tab.

    image

Create a resource by using a sample template

Creating resources of specific cloud services involves configuring numerous parameters. If you are not familiar with parameter configurations or want to experience a quick resource creation process by using Terraform, we recommend that you use a sample template to create a resource. Terraform Explorer provides one or more sample templates for each resource type. You can select a sample template to quickly complete debugging.

  1. On the Terraform Explorer page of OpenAPI Explorer, configure the Products, Resource Type, and Sample parameters and click Initiate Debugging. On the Code tab on the right, view the details of the sample template.

    image

  2. On the Debugging Code tab, click Plan & Apply.

    image

  3. On the Apply Details tab, view the execution result.

    image

  4. If you want to release the created resource, click Destroy Resources on the Apply Details tab. Then, click Apply on the Plan Details tab.

    image

Note

On the Debugging History tab, you can perform operations such as clicking Continue to continue debugging and clicking Destroy Resources to destroy a resource.