@@ -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
2121data "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
2626data "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
3636data "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