Terraform是一个开源用于资源编排管理的自动化工具。 Infrastructure as Code ,以代码的形式将所要管理的资源定义在模板中,通过解析并执行模板来自动化完成所定义资源的创建、变更和管理。以往博主交付某个项目都是人工创建基础资源,然后再用Ansible等工具进行应用程序部署,为了缩短交付时间,则使用terraform工具来创建基础资源,真香~
Initializing provider plugins... - Finding aliyun/alicloud versions matching "1.166.0"... ╷ │ Error: Failed to install provider │ │ Error while installing aliyun/alicloud v1.166.0: could not query provider registry for registry.terraform.io/aliyun/alicloud: failed to retrieve authentication checksums for provider: the request failed after 2 attempts, please try again later: Get │ "https://github.com/aliyun/terraform-provider-alicloud/releases/download/v1.166.0/terraform-provider-alicloud_1.166.0_SHA256SUMS": read tcp 192.168.174.135:39960->20.205.243.166:443: read: connection reset by peer ╵
Initializing provider plugins... - Finding aliyun/alicloud versions matching "1.166.0"... - Installing aliyun/alicloud v1.166.0... - Installed aliyun/alicloud v1.166.0 (signed by a HashiCorp partner, key ID 47422B4AA9FA381B)
Partner and community providers are signed by their developers. If you'd like to know more about provider signing, you can read about it here: https://www.terraform.io/docs/cli/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.
If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.
Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.
If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.
Initializing provider plugins... - Reusing previous version of local-registry/aliyun/alicloud from the dependency lock file - Finding hashicorp/aws versions matching "4.13.0"... - Finding hashicorp/azurerm versions matching "3.5.0"... - Finding hashicorp/google versions matching "4.20.0"... - Finding hashicorp/kubernetes versions matching "2.11.0"... - Using previously-installed local-registry/aliyun/alicloud v1.166.0 - Installing hashicorp/aws v4.13.0... - Installed hashicorp/aws v4.13.0 (signed by HashiCorp) - Installing hashicorp/azurerm v3.5.0... - Installed hashicorp/azurerm v3.5.0 (signed by HashiCorp) - Installing hashicorp/google v4.20.0... - Installed hashicorp/google v4.20.0 (signed by HashiCorp) - Installing hashicorp/kubernetes v2.11.0... - Installed hashicorp/kubernetes v2.11.0 (signed by HashiCorp)
Terraform has made some changes to the provider dependency selections recorded in the .terraform.lock.hcl file. Review those changes and commit them to your version control system if they represent changes you intended to make.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.
If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.
Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.
If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create
Terraform will perform the following actions:
# alicloud_security_group.default will be created + resource "alicloud_security_group" "default" { + id = (known after apply) + inner_access = (known after apply) + inner_access_policy = (known after apply) + name = "default" + security_group_type = "normal" + vpc_id = (known after apply) }
# alicloud_security_group_rule.allow_all_tcp will be created + resource "alicloud_security_group_rule" "allow_all_tcp" { + cidr_ip = "0.0.0.0/0" + id = (known after apply) + ip_protocol = "tcp" + nic_type = "intranet" + policy = "accept" + port_range = "1/65535" + prefix_list_id = (known after apply) + priority = 1 + security_group_id = (known after apply) + type = "ingress" }
# alicloud_vpc.main will be created + resource "alicloud_vpc" "main" { + cidr_block = "10.1.0.0/21" + id = (known after apply) + ipv6_cidr_block = (known after apply) + name = (known after apply) + resource_group_id = (known after apply) + route_table_id = (known after apply) + router_id = (known after apply) + router_table_id = (known after apply) + status = (known after apply) + vpc_name = "terraform-vpc" }
# alicloud_vswitch.main will be created + resource "alicloud_vswitch" "main" { + availability_zone = "cn-guangzhou-a" + cidr_block = "10.1.0.0/24" + id = (known after apply) + name = (known after apply) + status = (known after apply) + vpc_id = (known after apply) + vswitch_name = (known after apply) + zone_id = (known after apply) }
Plan: 4 to add, 0 to change, 0 to destroy. ╷ │ Warning: "availability_zone": [DEPRECATED] Field 'availability_zone' has been deprecated from provider version 1.119.0. New field 'zone_id' instead. │ │ with alicloud_vswitch.main, │ on terraform.tf line 13, in resource "alicloud_vswitch" "main": │ 13: resource "alicloud_vswitch" "main" { │ │ (and one more similar warning elsewhere) ╵
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create
Terraform will perform the following actions:
# alicloud_security_group.default will be created + resource "alicloud_security_group" "default" { + id = (known after apply) + inner_access = (known after apply) + inner_access_policy = (known after apply) + name = "default" + security_group_type = "normal" + vpc_id = (known after apply) }
# alicloud_security_group_rule.allow_all_tcp will be created + resource "alicloud_security_group_rule" "allow_all_tcp" { + cidr_ip = "0.0.0.0/0" + id = (known after apply) + ip_protocol = "tcp" + nic_type = "intranet" + policy = "accept" + port_range = "1/65535" + prefix_list_id = (known after apply) + priority = 1 + security_group_id = (known after apply) + type = "ingress" }
# alicloud_vpc.main will be created + resource "alicloud_vpc" "main" { + cidr_block = "10.1.0.0/21" + id = (known after apply) + ipv6_cidr_block = (known after apply) + name = (known after apply) + resource_group_id = (known after apply) + route_table_id = (known after apply) + router_id = (known after apply) + router_table_id = (known after apply) + status = (known after apply) + vpc_name = "terraform-vpc" }
# alicloud_vswitch.main will be created + resource "alicloud_vswitch" "main" { + availability_zone = "cn-guangzhou-a" + cidr_block = "10.1.0.0/24" + id = (known after apply) + name = (known after apply) + status = (known after apply) + vpc_id = (known after apply) + vswitch_name = (known after apply) + zone_id = (known after apply) }
Plan: 4 to add, 0 to change, 0 to destroy. ╷ │ Warning: "availability_zone": [DEPRECATED] Field 'availability_zone' has been deprecated from provider version 1.119.0. New field 'zone_id' instead. │ │ with alicloud_vswitch.main, │ on terraform.tf line 13, in resource "alicloud_vswitch" "main": │ 13: resource "alicloud_vswitch" "main" { │ │ (and one more similar warning elsewhere) ╵
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
alicloud_vpc.main: Creating... alicloud_vpc.main: Creation complete after 6s [id=vpc-7xvidwo6rkas2uwxf0274] alicloud_vswitch.main: Creating... alicloud_security_group.default: Creating... alicloud_security_group.default: Creation complete after 1s [id=sg-7xv2mzcim9shk3xtf2gt] alicloud_security_group_rule.allow_all_tcp: Creating... alicloud_security_group_rule.allow_all_tcp: Creation complete after 0s [id=sg-7xv2mzcim9shk3xtf2gt:ingress:tcp:1/65535:intranet:0.0.0.0/0:accept:1] alicloud_vswitch.main: Creation complete after 5s [id=vsw-7xvjdga6r3nvut6w2qith] ╷ │ Warning: "availability_zone": [DEPRECATED] Field 'availability_zone' has been deprecated from provider version 1.119.0. New field 'zone_id' instead. │ │ with alicloud_vswitch.main, │ on terraform.tf line 13, in resource "alicloud_vswitch" "main": │ 13: resource "alicloud_vswitch" "main" { │ ╵
Plan: 0 to add, 0 to change, 4 to destroy. ╷ │ Warning: "availability_zone": [DEPRECATED] Field 'availability_zone' has been deprecated from provider version 1.119.0. New field 'zone_id' instead. │ │ with alicloud_vswitch.main, │ on terraform.tf line 13, in resource "alicloud_vswitch" "main": │ 13: resource "alicloud_vswitch" "main" { │ ╵
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_vswitch.main: Destroying... [id=vsw-7xvjdga6r3nvut6w2qith] alicloud_security_group_rule.allow_all_tcp: Destroying... [id=sg-7xv2mzcim9shk3xtf2gt:ingress:tcp:1/65535:intranet:0.0.0.0/0:accept:1] alicloud_security_group_rule.allow_all_tcp: Destruction complete after 1s alicloud_security_group.default: Destroying... [id=sg-7xv2mzcim9shk3xtf2gt] alicloud_security_group.default: Destruction complete after 0s alicloud_vswitch.main: Destruction complete after 6s alicloud_vpc.main: Destroying... [id=vpc-7xvidwo6rkas2uwxf0274] alicloud_vpc.main: Destruction complete after 5s