Skip to content

Commit ea98e81

Browse files
tongyimingmikatong
andauthored
update cvm doc (#1966)
Co-authored-by: mikatong <mikatong@tencent.com>
1 parent bc336bc commit ea98e81

File tree

4 files changed

+70
-133
lines changed

4 files changed

+70
-133
lines changed

tencentcloud/resource_tc_cvm_launch_template.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
/*
2-
Provides a resource to create a cvm launch_template
2+
Provides a resource to create a cvm launch template
33
44
Example Usage
55
66
```hcl
7+
data "tencentcloud_images" "my_favorite_image" {
8+
image_type = ["PUBLIC_IMAGE"]
9+
image_name_regex = "Final"
10+
}
11+
712
resource "tencentcloud_cvm_launch_template" "demo" {
813
launch_template_name = "test"
914
placement {
1015
zone = "ap-guangzhou-6"
1116
project_id = 0
12-
host_ids = []
13-
host_ips = []
1417
}
15-
image_id = "img-xxxxxxxxx"
18+
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
1619
}
1720
```
1821
*/

tencentcloud/resource_tc_instance.go

Lines changed: 27 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ Provides a CVM instance resource.
33
44
~> **NOTE:** You can launch an CVM instance for a VPC network via specifying parameter `vpc_id`. One instance can only belong to one VPC.
55
6-
~> **NOTE:** At present, 'PREPAID' instance cannot be deleted and must wait it to be outdated and released automatically.
6+
~> **NOTE:** At present, 'PREPAID' instance cannot be deleted directly and must wait it to be outdated and released automatically.
77
88
Example Usage
99
1010
```hcl
1111
data "tencentcloud_images" "my_favorite_image" {
1212
image_type = ["PUBLIC_IMAGE"]
13-
os_name = "Tencent Linux release 3.2 (Final)"
13+
image_name_regex = "Final"
1414
}
1515
1616
data "tencentcloud_instance_types" "my_favorite_instance_types" {
1717
filter {
1818
name = "instance-family"
19-
values = ["S3"]
19+
values = ["S1", "S2", "S3", "S4", "S5"]
2020
}
2121
22-
cpu_core_count = 1
23-
memory_size = 1
22+
cpu_core_count = 2
23+
exclude_sold_out = true
2424
}
2525
2626
data "tencentcloud_availability_zones" "my_favorite_zones" {
@@ -39,9 +39,9 @@ resource "tencentcloud_subnet" "app" {
3939
cidr_block = "10.0.1.0/24"
4040
}
4141
42-
// Create 2 CVM instances to host awesome_app
43-
resource "tencentcloud_instance" "my_awesome_app" {
44-
instance_name = "awesome_app"
42+
// Create a POSTPAID_BY_HOUR CVM instance
43+
resource "tencentcloud_instance" "cvm_postpaid" {
44+
instance_name = "cvm_postpaid"
4545
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
4646
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
4747
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
@@ -51,7 +51,6 @@ resource "tencentcloud_instance" "my_awesome_app" {
5151
project_id = 0
5252
vpc_id = tencentcloud_vpc.app.id
5353
subnet_id = tencentcloud_subnet.app.id
54-
count = 2
5554
5655
data_disks {
5756
data_disk_type = "CLOUD_PREMIUM"
@@ -63,63 +62,30 @@ resource "tencentcloud_instance" "my_awesome_app" {
6362
tagKey = "tagValue"
6463
}
6564
}
66-
```
67-
68-
Create CVM instance based on CDH
69-
```hcl
70-
variable "availability_zone" {
71-
default = "ap-shanghai-4"
72-
}
7365
74-
resource "tencentcloud_cdh_instance" "foo" {
75-
availability_zone = var.availability_zone
76-
host_type = "HM50"
77-
charge_type = "PREPAID"
66+
// Create a PREPAID CVM instance
67+
resource "tencentcloud_instance" "cvm_prepaid" {
68+
instance_name = "cvm_prepaid"
69+
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
70+
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
71+
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
72+
system_disk_type = "CLOUD_PREMIUM"
73+
system_disk_size = 50
74+
hostname = "user"
75+
project_id = 0
76+
vpc_id = tencentcloud_vpc.app.id
77+
subnet_id = tencentcloud_subnet.app.id
78+
instance_charge_type = "PREPAID"
7879
instance_charge_type_prepaid_period = 1
79-
hostname = "test"
80-
prepaid_renew_flag = "DISABLE_NOTIFY_AND_MANUAL_RENEW"
81-
}
82-
83-
data "tencentcloud_cdh_instances" "list" {
84-
availability_zone = var.availability_zone
85-
host_id = tencentcloud_cdh_instance.foo.id
86-
hostname = "test"
87-
host_state = "RUNNING"
88-
}
89-
90-
resource "tencentcloud_key_pair" "random_key" {
91-
key_ids = ["tf_example_key6"]
92-
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw=="
93-
}
94-
95-
resource "tencentcloud_placement_group" "foo" {
96-
name = "test"
97-
type = "HOST"
98-
}
99-
100-
resource "tencentcloud_instance" "foo" {
101-
availability_zone = var.availability_zone
102-
instance_name = "terraform-testing"
103-
image_id = "img-ix05e4px"
104-
key_ids = [tencentcloud_key_pair.random_key.id]
105-
placement_group_id = tencentcloud_placement_group.foo.id
106-
security_groups = ["sg-9c3f33xk"]
107-
system_disk_type = "CLOUD_PREMIUM"
108-
109-
instance_charge_type = "CDHPAID"
110-
cdh_instance_type = "CDH_10C10G"
111-
cdh_host_id = tencentcloud_cdh_instance.foo.id
112-
113-
vpc_id = "vpc-31zmeluu"
114-
subnet_id = "subnet-aujc02np"
115-
allocate_public_ip = true
116-
internet_max_bandwidth_out = 2
117-
count = 3
118-
80+
instance_charge_type_prepaid_renew_flag = "NOTIFY_AND_MANUAL_RENEW"
11981
data_disks {
12082
data_disk_type = "CLOUD_PREMIUM"
12183
data_disk_size = 50
122-
encrypt = false
84+
encrypt = false
85+
}
86+
force_delete = true
87+
tags = {
88+
tagKey = "tagValue"
12389
}
12490
}
12591
```

website/docs/r/cvm_launch_template.html.markdown

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ layout: "tencentcloud"
44
page_title: "TencentCloud: tencentcloud_cvm_launch_template"
55
sidebar_current: "docs-tencentcloud-resource-cvm_launch_template"
66
description: |-
7-
Provides a resource to create a cvm launch_template
7+
Provides a resource to create a cvm launch template
88
---
99

1010
# tencentcloud_cvm_launch_template
1111

12-
Provides a resource to create a cvm launch_template
12+
Provides a resource to create a cvm launch template
1313

1414
## Example Usage
1515

1616
```hcl
17+
data "tencentcloud_images" "my_favorite_image" {
18+
image_type = ["PUBLIC_IMAGE"]
19+
image_name_regex = "Final"
20+
}
21+
1722
resource "tencentcloud_cvm_launch_template" "demo" {
1823
launch_template_name = "test"
1924
placement {
2025
zone = "ap-guangzhou-6"
2126
project_id = 0
22-
host_ids = []
23-
host_ips = []
2427
}
25-
image_id = "img-xxxxxxxxx"
28+
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
2629
}
2730
```
2831

website/docs/r/instance.html.markdown

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ Provides a CVM instance resource.
1313

1414
~> **NOTE:** You can launch an CVM instance for a VPC network via specifying parameter `vpc_id`. One instance can only belong to one VPC.
1515

16-
~> **NOTE:** At present, 'PREPAID' instance cannot be deleted and must wait it to be outdated and released automatically.
16+
~> **NOTE:** At present, 'PREPAID' instance cannot be deleted directly and must wait it to be outdated and released automatically.
1717

1818
## Example Usage
1919

2020
```hcl
2121
data "tencentcloud_images" "my_favorite_image" {
22-
image_type = ["PUBLIC_IMAGE"]
23-
os_name = "Tencent Linux release 3.2 (Final)"
22+
image_type = ["PUBLIC_IMAGE"]
23+
image_name_regex = "Final"
2424
}
2525
2626
data "tencentcloud_instance_types" "my_favorite_instance_types" {
2727
filter {
2828
name = "instance-family"
29-
values = ["S3"]
29+
values = ["S1", "S2", "S3", "S4", "S5"]
3030
}
3131
32-
cpu_core_count = 1
33-
memory_size = 1
32+
cpu_core_count = 2
33+
exclude_sold_out = true
3434
}
3535
3636
data "tencentcloud_availability_zones" "my_favorite_zones" {
@@ -49,9 +49,9 @@ resource "tencentcloud_subnet" "app" {
4949
cidr_block = "10.0.1.0/24"
5050
}
5151
52-
// Create 2 CVM instances to host awesome_app
53-
resource "tencentcloud_instance" "my_awesome_app" {
54-
instance_name = "awesome_app"
52+
// Create a POSTPAID_BY_HOUR CVM instance
53+
resource "tencentcloud_instance" "cvm_postpaid" {
54+
instance_name = "cvm_postpaid"
5555
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
5656
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
5757
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
@@ -61,7 +61,6 @@ resource "tencentcloud_instance" "my_awesome_app" {
6161
project_id = 0
6262
vpc_id = tencentcloud_vpc.app.id
6363
subnet_id = tencentcloud_subnet.app.id
64-
count = 2
6564
6665
data_disks {
6766
data_disk_type = "CLOUD_PREMIUM"
@@ -73,65 +72,31 @@ resource "tencentcloud_instance" "my_awesome_app" {
7372
tagKey = "tagValue"
7473
}
7574
}
76-
```
77-
78-
### Create CVM instance based on CDH
79-
80-
```hcl
81-
variable "availability_zone" {
82-
default = "ap-shanghai-4"
83-
}
84-
85-
resource "tencentcloud_cdh_instance" "foo" {
86-
availability_zone = var.availability_zone
87-
host_type = "HM50"
88-
charge_type = "PREPAID"
89-
instance_charge_type_prepaid_period = 1
90-
hostname = "test"
91-
prepaid_renew_flag = "DISABLE_NOTIFY_AND_MANUAL_RENEW"
92-
}
93-
94-
data "tencentcloud_cdh_instances" "list" {
95-
availability_zone = var.availability_zone
96-
host_id = tencentcloud_cdh_instance.foo.id
97-
hostname = "test"
98-
host_state = "RUNNING"
99-
}
100-
101-
resource "tencentcloud_key_pair" "random_key" {
102-
key_ids = ["tf_example_key6"]
103-
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw=="
104-
}
105-
106-
resource "tencentcloud_placement_group" "foo" {
107-
name = "test"
108-
type = "HOST"
109-
}
110-
111-
resource "tencentcloud_instance" "foo" {
112-
availability_zone = var.availability_zone
113-
instance_name = "terraform-testing"
114-
image_id = "img-ix05e4px"
115-
key_ids = [tencentcloud_key_pair.random_key.id]
116-
placement_group_id = tencentcloud_placement_group.foo.id
117-
security_groups = ["sg-9c3f33xk"]
118-
system_disk_type = "CLOUD_PREMIUM"
119-
120-
instance_charge_type = "CDHPAID"
121-
cdh_instance_type = "CDH_10C10G"
122-
cdh_host_id = tencentcloud_cdh_instance.foo.id
123-
124-
vpc_id = "vpc-31zmeluu"
125-
subnet_id = "subnet-aujc02np"
126-
allocate_public_ip = true
127-
internet_max_bandwidth_out = 2
128-
count = 3
12975
76+
// Create a PREPAID CVM instance
77+
resource "tencentcloud_instance" "cvm_prepaid" {
78+
instance_name = "cvm_prepaid"
79+
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
80+
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
81+
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
82+
system_disk_type = "CLOUD_PREMIUM"
83+
system_disk_size = 50
84+
hostname = "user"
85+
project_id = 0
86+
vpc_id = tencentcloud_vpc.app.id
87+
subnet_id = tencentcloud_subnet.app.id
88+
instance_charge_type = "PREPAID"
89+
instance_charge_type_prepaid_period = 1
90+
instance_charge_type_prepaid_renew_flag = "NOTIFY_AND_MANUAL_RENEW"
13091
data_disks {
13192
data_disk_type = "CLOUD_PREMIUM"
13293
data_disk_size = 50
13394
encrypt = false
13495
}
96+
force_delete = true
97+
tags = {
98+
tagKey = "tagValue"
99+
}
135100
}
136101
```
137102

0 commit comments

Comments
 (0)