4. 使用Terraform销毁资源
|
[root@test01 terraform]# export ALICLOUD_ACCESS_KEY="LTAIUrZCw3********" [root@test01 terraform]# export ALICLOUD_SECRET_KEY="zfwwWAMWIAiooj14GQ2*************" [root@test01 terraform]# export ALICLOUD_REGION="cn-beijing" |
|
[root@test01 terraform]# ./terraform destroy alicloud_vpc.vpc: Refreshing state... [id=vpc-2zesgdbuik6y61rxq0p02] alicloud_security_group.default: Refreshing state... [id=sg-2zegv9wljzw95euqq0af] alicloud_vswitch.vsw: Refreshing state... [id=vsw-2ze43xp7uw2clumb7hsb4] alicloud_instance.instance: Refreshing state... [id=i-2ze37621ou0ezxp4fros] alicloud_security_group_rule.allow_all_tcp: Refreshing state... [id=sg-2zegv9wljzw95euqq0af:ingress:tcp:1/65535:intranet:0.0.0.0/0:accept:1]
An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: - destroy
Terraform will perform the following actions:
# alicloud_instance.instance will be destroyed - resource "alicloud_instance" "instance" { - availability_zone = "cn-beijing-b" -> null - deletion_protection = false -> null - host_name = "iZ2ze37621ou0ezxp4frosZ" -> null - id = "i-2ze37621ou0ezxp4fros" -> null - image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd" -> null - instance_charge_type = "PostPaid" -> null - instance_name = "test_foo" -> null - instance_type = "ecs.n2.small" -> null - internet_charge_type = "PayByTraffic" -> null - internet_max_bandwidth_in = -1 -> null - internet_max_bandwidth_out = 10 -> null - password = (sensitive value) - private_ip = "172.16.4.240" -> null - public_ip = "**.**.**.**" -> null - security_groups = [ - "sg-2zegv9wljzw95euqq0af", ] -> null - spot_price_limit = 0 -> null - spot_strategy = "NoSpot" -> null - status = "Running" -> null - subnet_id = "vsw-2ze43xp7uw2clumb7hsb4" -> null - system_disk_category = "cloud_efficiency" -> null - system_disk_size = 40 -> null - volume_tags = {} -> null - vswitch_id = "vsw-2ze43xp7uw2clumb7hsb4" -> null }
# alicloud_security_group.default will be destroyed - resource "alicloud_security_group" "default" { - id = "sg-2zegv9wljzw95euqq0af" -> null - inner_access = true -> null - name = "default" -> null - vpc_id = "vpc-2zesgdbuik6y61rxq0p02" -> null }
# alicloud_security_group_rule.allow_all_tcp will be destroyed - resource "alicloud_security_group_rule" "allow_all_tcp" { - cidr_ip = "0.0.0.0/0" -> null - id = "sg-2zegv9wljzw95euqq0af:ingress:tcp:1/65535:intranet:0.0.0.0/0:accept:1" -> null - ip_protocol = "tcp" -> null - nic_type = "intranet" -> null - policy = "accept" -> null - port_range = "1/65535" -> null - priority = 1 -> null - security_group_id = "sg-2zegv9wljzw95euqq0af" -> null - type = "ingress" -> null }
# alicloud_vpc.vpc will be destroyed - resource "alicloud_vpc" "vpc" { - cidr_block = "172.16.0.0/12" -> null - id = "vpc-2zesgdbuik6y61rxq0p02" -> null - name = "tf_test_foo" -> null - resource_group_id = "rg-acfmxg55owv3yby" -> null - route_table_id = "vtb-2zepwgxl0erv9z8xb52tw" -> null - router_id = "vrt-2zev28tc0onnunmyk7n2r" -> null - router_table_id = "vtb-2zepwgxl0erv9z8xb52tw" -> null }
# alicloud_vswitch.vsw will be destroyed - resource "alicloud_vswitch" "vsw" { - availability_zone = "cn-beijing-b" -> null - cidr_block = "172.16.0.0/21" -> null - id = "vsw-2ze43xp7uw2clumb7hsb4" -> null - vpc_id = "vpc-2zesgdbuik6y61rxq0p02" -> null }
Plan: 0 to add, 0 to change, 5 to destroy.
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
alicloud_security_group_rule.allow_all_tcp: Destroying... [id=sg-2zegv9wljzw95euqq0af:ingress:tcp:1/65535:intranet:0.0.0.0/0:accept:1] alicloud_instance.instance: Destroying... [id=i-2ze37621ou0ezxp4fros] alicloud_security_group_rule.allow_all_tcp: Destruction complete after 1s alicloud_instance.instance: Still destroying... [id=i-2ze37621ou0ezxp4fros, 10s elapsed] alicloud_instance.instance: Destruction complete after 11s alicloud_vswitch.vsw: Destroying... [id=vsw-2ze43xp7uw2clumb7hsb4] alicloud_security_group.default: Destroying... [id=sg-2zegv9wljzw95euqq0af] alicloud_vswitch.vsw: Still destroying... [id=vsw-2ze43xp7uw2clumb7hsb4, 10s elapsed] alicloud_security_group.default: Still destroying... [id=sg-2zegv9wljzw95euqq0af, 10s elapsed] alicloud_vswitch.vsw: Still destroying... [id=vsw-2ze43xp7uw2clumb7hsb4, 20s elapsed] alicloud_security_group.default: Still destroying... [id=sg-2zegv9wljzw95euqq0af, 20s elapsed] alicloud_vswitch.vsw: Destruction complete after 27s alicloud_security_group.default: Destruction complete after 28s alicloud_vpc.vpc: Destroying... [id=vpc-2zesgdbuik6y61rxq0p02] alicloud_vpc.vpc: Destruction complete after 2s
Destroy complete! Resources: 5 destroyed. [root@test01 terraform]# |
|
[root@test01 terraform]# ./terraform show |

浙公网安备 33010602011771号