$ terraform plan An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create
Terraform will perform the following actions:
# huaweicloud_vpc.main will be created + resource "huaweicloud_vpc" "main" { + cidr = "192.168.0.0/16" + enterprise_project_id = (known after apply) + id = (known after apply) + name = "net1" + region = (known after apply) + routes = (known after apply) + shared = (known after apply) + status = (known after apply) }
# huaweicloud_vpc_subnet.main will be created + resource "huaweicloud_vpc_subnet" "main" { + availability_zone = "cn-east-2a" + cidr = "192.168.1.0/24" + dhcp_enable = true + dns_list = [ + "100.125.17.29", + "100.125.135.29", ] + gateway_ip = "192.168.1.1" + id = (known after apply) + name = "zone1-1" + primary_dns = (known after apply) + region = (known after apply) + secondary_dns = (known after apply) + subnet_id = (known after apply) + vpc_id = (known after apply) }
Note: You didn't specify an "-out" parameter to save this plan, so Terraform can't guarantee that exactly these actions will be performed if "terraform apply" is subsequently run.
可以看到,terraform将创建两个资源huaweicloud_vpc.main和huaweicloud_vpc_subnet.main,它们的某些属性为known after apply,这个意思是说该参数的值需要在执行terraform apply之后才能知道,通常像这样的字段如果没有显示的设置值,云平台将会自动生成。
$ terraform apply An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create
Terraform will perform the following actions:
# huaweicloud_vpc.main will be created + resource "huaweicloud_vpc" "main" { + cidr = "192.168.0.0/16" + enterprise_project_id = (known after apply) + id = (known after apply) + name = "net1" + region = (known after apply) + routes = (known after apply) + shared = (known after apply) + status = (known after apply) }
# huaweicloud_vpc_subnet.main will be created + resource "huaweicloud_vpc_subnet" "main" { + availability_zone = "cn-east-2a" + cidr = "192.168.1.0/24" + dhcp_enable = true + dns_list = [ + "100.125.17.29", + "100.125.135.29", ] + gateway_ip = "192.168.1.1" + id = (known after apply) + name = "zone1-1" + primary_dns = (known after apply) + region = (known after apply) + secondary_dns = (known after apply) + subnet_id = (known after apply) + vpc_id = (known after apply) }
Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.
Enter a value: yes
huaweicloud_vpc.main: Creating... huaweicloud_vpc.main: Creation complete after 6s [id=867655c8-7641-4fbf-b8c4-34989e560d46] huaweicloud_vpc_subnet.main: Creating... huaweicloud_vpc_subnet.main: Creation complete after 8s [id=a35290c9-d9c5-4ee0-a24f-1fe65c88c0b8]
原地变更(update in place),即在不改变资源生命周期的情况下,实现对资源属性的修改,如变更资源的名称、描述、便签等。
重建变更(destroy and then create replacemnt),资源的某些属性是不支持变更的,在这种情况下,如果修改资源属性,Terraform会先删除原有资源,然后按照最新的模板定义创建新的资源,从而间接实现资源的变更操作。对于不支持变更的属性,在各云厂商的provider文档中,会将该属性显示的声明为ForceNew。
An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: -/+ destroy and then create replacement
Terraform will perform the following actions:
# huaweicloud_vpc_subnet.main must be replaced -/+ resource "huaweicloud_vpc_subnet" "main" { ~ cidr = "192.168.1.0/24" -> "192.168.2.0/24" # forces replacement ~ gateway_ip = "192.168.1.1" -> "192.168.2.1" # forces replacement ~ id = "73b58ff0-0a3c-43db-927a-a4804e600a2d" -> (known after apply) name = "zone1-1" ~ primary_dns = "100.125.17.29" -> (known after apply) ~ region = "cn-east-2" -> (known after apply) ~ secondary_dns = "100.125.135.29" -> (known after apply) ~ subnet_id = "a5870016-b575-45ec-b7a7-538f35c46b13" -> (known after apply) - tags = {} -> null # (4 unchanged attributes hidden) }
Plan: 1 to add, 0 to change, 1 to destroy.
Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.
Enter a value: yes
huaweicloud_vpc_subnet.main: Destroying... [id=73b58ff0-0a3c-43db-927a-a4804e600a2d] huaweicloud_vpc_subnet.main: Destruction complete after 9s huaweicloud_vpc_subnet.main: Creating... huaweicloud_vpc_subnet.main: Creation complete after 9s [id=efc326dd-b911-4ce4-b6b4-11cc53bf690e]
Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm.
You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.
Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
huaweicloud_vpc_subnet.main: Destroying... [id=77bc0afc-9bf8-492d-af83-bdbe76dfbdda] huaweicloud_vpc_subnet.main: Destruction complete after 10s
Warning: Applied changes may be incomplete
The plan was created with the -target option in effect, so some changes requested in the configuration may have been ignored and the output values may not be fully updated. Run the following command to verify that no other changes are pending: terraform plan
Note that the -target option is not suitable for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.