This topic provides an example of 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. It is designed to help developers simplify the processes of writing Terraform configuration files and operating Terraform while lowering the barrier to entry. 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 lets you create resources by configuring custom parameters or using a sample template. You can use either method to create resources as needed.
Create a resource by configuring custom parameters
You can create an Alibaba Cloud resource by configuring custom parameters as needed.
On the Terraform Explorer page, configure the Products and Resource Type parameters, configure the parameters in the Documentation section based on the instructions, and then click Parameters, 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.
On the Debugging Code tab, view the input parameters. After you confirm that the parameters are correct, click Plan to view the execution plan generated by Terraform.
On the Plan Details tab, view the details of the resource that you want to create. After you confirm that the information is correct, click Apply to view the execution result of Terraform.
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.
On the Resource Details tab, view the information about the created resource.
If you want to modify the information about the created resource, adjust the related parameters and click Save And Continue. Then, repeat Step 2, Step 3, and Step 4. After the execution is complete, you can view the execution result on the Apply Details tab. If the execution is successful, the following message appears: "Apply complete! Resources: 0 added, 1 changed, 0 destroyed." If the execution fails, adjust the parameters as prompted and click Save and Continue.
If you want to release the created resource, click the Apply Details tab, click Destroy Resources, and then click the Plan Details tab, click Apply to release the resource.
Create a resource 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 using Terraform, we recommend that you use a sample template to create a resource. Terraform Explorer provides sample templates for each resource type. You can select one of the sample templates to quickly complete debugging.
On the Terraform Explorer page, configure the Products, Resource Type, and Sample parameters, and click Initiate Debugging. You can view the details of the sample template on the Sample tab on the right.
On the Template Details tab, click Preview And Execute.
On the Apply Details tab, view the execution result.
If you want to release the created resource, click the Apply Details tab, click Destroy Resources, and then click the Plan Details tab, click Apply to release the resource.
You can also perform operations such as Continue debugging and Destroy Resources on the Debugging History tab.