<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## 創建一臺主機的需求 ## 1. 2.5 GHz主頻的Intel Xeon E5-2680 v3 1個cpu 2. 1GIB內存 3. 硬盤 40g 高效云盤 4. 網絡和交換機(內網/外網IP) ## 安裝阿里云cli ## 1. 下載 https://s3.amazonaws.com/aws-cli/AWSCLI64.msi并安裝 ## 注冊并使用阿里云 ## 1. 可以使用支付寶注冊登錄(暫時省略) 2. 使用系統默認的access key(暫時不考慮安全和權限的問題) 3. 登錄阿里云->點擊頭像->access key管理->繼續使用access key AccessKey ID | 狀態 | 最后使用時間 | 創建時間 | 操作 -|-|-|-|- AccessKeyId | 已啟用 | 2021年4月30日17:22:56 | 2021年4月29日11:04:17 | 查看 Secret 禁用 刪除 4. 在cmd 運行aliyun configure --profile course,分別輸入 ``` Access Key Id [*********************BVw]: Access Key Secret [***************************Qht]: Default Region Id [cn-qingdao]: Default Output Format [json]: json (Only support json) Default Language [zh|en] en: ``` ## 用一個最簡單的例子創建一個linux主機 ## 1. main.tf ``` provider "alicloud" { profile = "course" region = "cn-qingdao" } resource "alicloud_instance" "server" { # image id image_id = "centos_7_7_x64_20G_alibase_20200329.vhd" # 根據流量付費 internet_charge_type = "PayByTraffic" # 主機類型 instance_type = "ecs.n1.tiny" # 主機名 instance_name = "aliyun-lab-02" # 密碼 password = "1234Qwer" # 自帶外網ipv4 配置 # 設置internet_max_bandwidth_out > 0 可以分配一個public IP internet_max_bandwidth_out = "100" # 設置專有網絡 vswitch_id = alicloud_vswitch.vswitch.id # secrity group security_groups = ["${alicloud_security_group.sg.id}"] } # 創建security group resource "alicloud_security_group" "sg" { vpc_id = alicloud_vpc.vpc.id } # 創建專有網絡 resource "alicloud_vpc" "vpc" { cidr_block = "172.16.0.0/16" } # 創建交換機 resource "alicloud_vswitch" "vswitch" { vpc_id = alicloud_vpc.vpc.id cidr_block = "172.16.0.0/24" zone_id = data.alicloud_zones.default.zones[0].id } # 查詢可用區 data "alicloud_zones" "default" { available_instance_type = data.alicloud_instance_types.instance_type.instance_types[0].id } # 查詢能用的主機類型 data "alicloud_instance_types" "instance_type" { instance_type_family = "ecs.n1" cpu_core_count = "1" memory_size = "1" } ``` 2. 運行terraform init /plan /apply 輸入yes ``` D:\course\example\1.02>terraform init Initializing the backend... Initializing provider plugins... - Reusing previous version of hashicorp/alicloud from the dependency lock file - Installing hashicorp/alicloud v1.122.0... - Installed hashicorp/alicloud v1.122.0 (self-signed, key ID 34365D9472D7468F) 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/plugins/signing.html Warning: Additional provider information from registry The remote registry returned warnings for registry.terraform.io/hashicorp/alicloud: - For users on Terraform 0.13 or greater, this provider has moved to aliyun/alicloud. Please update your source in required_providers. Warning: Quoted references are deprecated on main.tf line 12, in resource "alicloud_instance" "web": 12: provider = "alicloud" In this context, references are expected literally rather than in quotes. Terraform 0.11 and earlier required quotes, but quoted references are now deprecated and will be removed in a future version of Terraform. Remove the quotes surrounding this reference to silence this warning. Warning: Interpolation-only expressions are deprecated on main.tf line 20, in resource "alicloud_instance" "web": 20: security_groups = ["${alicloud_security_group.group.id}"] Terraform 0.11 and earlier required all non-constant expressions to be provided via interpolation syntax, but this pattern is now deprecated. To silence this warning, remove the "${ sequence from the start and the }" sequence from the end of this expression, leaving just the inner expression. Template interpolation syntax is still used to construct strings from expressions when the template includes multiple interpolation sequences or a mixture of literal strings and interpolations. This deprecation applies only to templates that consist entirely of a single interpolation sequence. 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. D:\course\example\1.02>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: # alicloud_instance.web will be created + resource "alicloud_instance" "web" { + availability_zone = (known after apply) + credit_specification = (known after apply) + deletion_protection = false + dry_run = false + host_name = (known after apply) + id = (known after apply) + image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd" + instance_charge_type = "PostPaid" + instance_name = "web" + instance_type = "ecs.n1.tiny" + internet_max_bandwidth_in = (known after apply) + internet_max_bandwidth_out = 0 + io_optimized = "optimized" + key_name = (known after apply) + private_ip = (known after apply) + public_ip = (known after apply) + role_name = (known after apply) + security_groups = (known after apply) + spot_strategy = "NoSpot" + status = "Running" + subnet_id = (known after apply) + system_disk_category = "cloud_efficiency" + system_disk_performance_level = (known after apply) + system_disk_size = 40 + volume_tags = (known after apply) + vswitch_id = (known after apply) } # alicloud_security_group.group will be created + resource "alicloud_security_group" "group" { + id = (known after apply) + inner_access = (known after apply) + inner_access_policy = (known after apply) + name = "my_secutiry_group" + security_group_type = "normal" + vpc_id = (known after apply) } # alicloud_vpc.vpc will be created + resource "alicloud_vpc" "vpc" { + cidr_block = "172.16.0.0/16" + enable_ipv6 = false + 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 = "my_vpc" } # alicloud_vswitch.vswitch will be created + resource "alicloud_vswitch" "vswitch" { + availability_zone = (known after apply) + cidr_block = "172.16.0.0/24" + id = (known after apply) + name = (known after apply) + status = (known after apply) + vpc_id = (known after apply) + vswitch_name = "my_switch" + zone_id = "cn-qingdao-b" } Plan: 4 to add, 0 to change, 0 to destroy. Warning: "io_optimized": [DEPRECATED] Attribute io_optimized has been deprecated on instance resource. All the launched alicloud instances will be IO optimized. Suggest to remove it from your template. on main.tf line 10, in resource "alicloud_instance" "web": 10: resource "alicloud_instance" "web" { Warning: Quoted references are deprecated on main.tf line 12, in resource "alicloud_instance" "web": 12: provider = "alicloud" In this context, references are expected literally rather than in quotes. Terraform 0.11 and earlier required quotes, but quoted references are now deprecated and will be removed in a future version of Terraform. Remove the quotes surrounding this reference to silence this warning. Warning: Interpolation-only expressions are deprecated on main.tf line 20, in resource "alicloud_instance" "web": 20: security_groups = ["${alicloud_security_group.group.id}"] Terraform 0.11 and earlier required all non-constant expressions to be provided via interpolation syntax, but this pattern is now deprecated. To silence this warning, remove the "${ sequence from the start and the }" sequence from the end of this expression, leaving just the inner expression. Template interpolation syntax is still used to construct strings from expressions when the template includes multiple interpolation sequences or a mixture of literal strings and interpolations. This deprecation applies only to templates that consist entirely of a single interpolation sequence. 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.vpc: Creating... alicloud_vpc.vpc: Creation complete after 6s [id=vpc-m5enazzdoyz6q50nusgty] alicloud_security_group.group: Creating... alicloud_vswitch.vswitch: Creating... alicloud_security_group.group: Creation complete after 2s [id=sg-m5e5motrcqfyzwavqfl8] alicloud_vswitch.vswitch: Creation complete after 6s [id=vsw-m5ej840mcxi56a8e2tae0] alicloud_instance.web: Creating... alicloud_instance.web: Still creating... [10s elapsed] alicloud_instance.web: Still creating... [20s elapsed] alicloud_instance.web: Still creating... [30s elapsed] alicloud_instance.web: Creation complete after 33s [id=i-m5e5buxy1fal6swuthub] Apply complete! Resources: 4 added, 0 changed, 0 destroyed. ``` 3. 查看阿里云后臺,發現一臺web主機已經被創建 4. 執行terraform destroy 輸入yes 銷毀主機以及關聯資源 實例ID/名稱 | 標簽 | 監控 | 可用區 | IP地址 | 狀態 | 配置 | 付費方式 -|-|-|-|-|-|-|- i-m5e8nuefjsnx3bhjdkyi web | - |青島 可用區B | 172.16.0.5(私有) |運行中 |1 vCPU 1 GiB (I/O優化) | ecs.n1.tiny 0Mbps (峰值) | 按量 | 2021年5月6日16:23 創建 5. 查看當前terraform生成的文件 ``` D:\course\example\1.02>dir Volume in drive D is UserProfile Volume Serial Number is 8A16-AC57 Directory of D:\course\example\1.02 2021/05/06 16:29 <DIR> . 2021/05/06 16:29 <DIR> .. 2021/05/06 14:26 <DIR> .terraform 2021/05/06 16:17 1,083 .terraform.lock.hcl 2021/05/06 16:10 1,341 main.tf 2021/05/06 16:29 157 terraform.tfstate 2021/05/06 16:28 7,463 terraform.tfstate.backup 4 File(s) 10,044 bytes 3 Dir(s) 97,182,687,232 bytes free ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看