Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tencentcloud/resource_tc_cvm_launch_template.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
/*
Provides a resource to create a cvm launch_template
Provides a resource to create a cvm launch template

Example Usage

```hcl
data "tencentcloud_images" "my_favorite_image" {
image_type = ["PUBLIC_IMAGE"]
image_name_regex = "Final"
}

resource "tencentcloud_cvm_launch_template" "demo" {
launch_template_name = "test"
placement {
zone = "ap-guangzhou-6"
project_id = 0
host_ids = []
host_ips = []
}
image_id = "img-xxxxxxxxx"
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
}
```
*/
Expand Down
88 changes: 27 additions & 61 deletions tencentcloud/resource_tc_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ Provides a CVM instance resource.

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

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

Example Usage

```hcl
data "tencentcloud_images" "my_favorite_image" {
image_type = ["PUBLIC_IMAGE"]
os_name = "Tencent Linux release 3.2 (Final)"
image_name_regex = "Final"
}

data "tencentcloud_instance_types" "my_favorite_instance_types" {
filter {
name = "instance-family"
values = ["S3"]
values = ["S1", "S2", "S3", "S4", "S5"]
}

cpu_core_count = 1
memory_size = 1
cpu_core_count = 2
exclude_sold_out = true
}

data "tencentcloud_availability_zones" "my_favorite_zones" {
Expand All @@ -39,9 +39,9 @@ resource "tencentcloud_subnet" "app" {
cidr_block = "10.0.1.0/24"
}

// Create 2 CVM instances to host awesome_app
resource "tencentcloud_instance" "my_awesome_app" {
instance_name = "awesome_app"
// Create a POSTPAID_BY_HOUR CVM instance
resource "tencentcloud_instance" "cvm_postpaid" {
instance_name = "cvm_postpaid"
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
Expand All @@ -51,7 +51,6 @@ resource "tencentcloud_instance" "my_awesome_app" {
project_id = 0
vpc_id = tencentcloud_vpc.app.id
subnet_id = tencentcloud_subnet.app.id
count = 2

data_disks {
data_disk_type = "CLOUD_PREMIUM"
Expand All @@ -63,63 +62,30 @@ resource "tencentcloud_instance" "my_awesome_app" {
tagKey = "tagValue"
}
}
```

Create CVM instance based on CDH
```hcl
variable "availability_zone" {
default = "ap-shanghai-4"
}

resource "tencentcloud_cdh_instance" "foo" {
availability_zone = var.availability_zone
host_type = "HM50"
charge_type = "PREPAID"
// Create a PREPAID CVM instance
resource "tencentcloud_instance" "cvm_prepaid" {
instance_name = "cvm_prepaid"
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
system_disk_type = "CLOUD_PREMIUM"
system_disk_size = 50
hostname = "user"
project_id = 0
vpc_id = tencentcloud_vpc.app.id
subnet_id = tencentcloud_subnet.app.id
instance_charge_type = "PREPAID"
instance_charge_type_prepaid_period = 1
hostname = "test"
prepaid_renew_flag = "DISABLE_NOTIFY_AND_MANUAL_RENEW"
}

data "tencentcloud_cdh_instances" "list" {
availability_zone = var.availability_zone
host_id = tencentcloud_cdh_instance.foo.id
hostname = "test"
host_state = "RUNNING"
}

resource "tencentcloud_key_pair" "random_key" {
key_ids = ["tf_example_key6"]
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw=="
}

resource "tencentcloud_placement_group" "foo" {
name = "test"
type = "HOST"
}

resource "tencentcloud_instance" "foo" {
availability_zone = var.availability_zone
instance_name = "terraform-testing"
image_id = "img-ix05e4px"
key_ids = [tencentcloud_key_pair.random_key.id]
placement_group_id = tencentcloud_placement_group.foo.id
security_groups = ["sg-9c3f33xk"]
system_disk_type = "CLOUD_PREMIUM"

instance_charge_type = "CDHPAID"
cdh_instance_type = "CDH_10C10G"
cdh_host_id = tencentcloud_cdh_instance.foo.id

vpc_id = "vpc-31zmeluu"
subnet_id = "subnet-aujc02np"
allocate_public_ip = true
internet_max_bandwidth_out = 2
count = 3

instance_charge_type_prepaid_renew_flag = "NOTIFY_AND_MANUAL_RENEW"
data_disks {
data_disk_type = "CLOUD_PREMIUM"
data_disk_size = 50
encrypt = false
encrypt = false
}
force_delete = true
tags = {
tagKey = "tagValue"
}
}
```
Expand Down
13 changes: 8 additions & 5 deletions website/docs/r/cvm_launch_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ layout: "tencentcloud"
page_title: "TencentCloud: tencentcloud_cvm_launch_template"
sidebar_current: "docs-tencentcloud-resource-cvm_launch_template"
description: |-
Provides a resource to create a cvm launch_template
Provides a resource to create a cvm launch template
---

# tencentcloud_cvm_launch_template

Provides a resource to create a cvm launch_template
Provides a resource to create a cvm launch template

## Example Usage

```hcl
data "tencentcloud_images" "my_favorite_image" {
image_type = ["PUBLIC_IMAGE"]
image_name_regex = "Final"
}

resource "tencentcloud_cvm_launch_template" "demo" {
launch_template_name = "test"
placement {
zone = "ap-guangzhou-6"
project_id = 0
host_ids = []
host_ips = []
}
image_id = "img-xxxxxxxxx"
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
}
```

Expand Down
91 changes: 28 additions & 63 deletions website/docs/r/instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ Provides a CVM instance resource.

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

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

## Example Usage

```hcl
data "tencentcloud_images" "my_favorite_image" {
image_type = ["PUBLIC_IMAGE"]
os_name = "Tencent Linux release 3.2 (Final)"
image_type = ["PUBLIC_IMAGE"]
image_name_regex = "Final"
}

data "tencentcloud_instance_types" "my_favorite_instance_types" {
filter {
name = "instance-family"
values = ["S3"]
values = ["S1", "S2", "S3", "S4", "S5"]
}

cpu_core_count = 1
memory_size = 1
cpu_core_count = 2
exclude_sold_out = true
}

data "tencentcloud_availability_zones" "my_favorite_zones" {
Expand All @@ -49,9 +49,9 @@ resource "tencentcloud_subnet" "app" {
cidr_block = "10.0.1.0/24"
}

// Create 2 CVM instances to host awesome_app
resource "tencentcloud_instance" "my_awesome_app" {
instance_name = "awesome_app"
// Create a POSTPAID_BY_HOUR CVM instance
resource "tencentcloud_instance" "cvm_postpaid" {
instance_name = "cvm_postpaid"
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
Expand All @@ -61,7 +61,6 @@ resource "tencentcloud_instance" "my_awesome_app" {
project_id = 0
vpc_id = tencentcloud_vpc.app.id
subnet_id = tencentcloud_subnet.app.id
count = 2

data_disks {
data_disk_type = "CLOUD_PREMIUM"
Expand All @@ -73,65 +72,31 @@ resource "tencentcloud_instance" "my_awesome_app" {
tagKey = "tagValue"
}
}
```

### Create CVM instance based on CDH

```hcl
variable "availability_zone" {
default = "ap-shanghai-4"
}

resource "tencentcloud_cdh_instance" "foo" {
availability_zone = var.availability_zone
host_type = "HM50"
charge_type = "PREPAID"
instance_charge_type_prepaid_period = 1
hostname = "test"
prepaid_renew_flag = "DISABLE_NOTIFY_AND_MANUAL_RENEW"
}

data "tencentcloud_cdh_instances" "list" {
availability_zone = var.availability_zone
host_id = tencentcloud_cdh_instance.foo.id
hostname = "test"
host_state = "RUNNING"
}

resource "tencentcloud_key_pair" "random_key" {
key_ids = ["tf_example_key6"]
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw=="
}

resource "tencentcloud_placement_group" "foo" {
name = "test"
type = "HOST"
}

resource "tencentcloud_instance" "foo" {
availability_zone = var.availability_zone
instance_name = "terraform-testing"
image_id = "img-ix05e4px"
key_ids = [tencentcloud_key_pair.random_key.id]
placement_group_id = tencentcloud_placement_group.foo.id
security_groups = ["sg-9c3f33xk"]
system_disk_type = "CLOUD_PREMIUM"

instance_charge_type = "CDHPAID"
cdh_instance_type = "CDH_10C10G"
cdh_host_id = tencentcloud_cdh_instance.foo.id

vpc_id = "vpc-31zmeluu"
subnet_id = "subnet-aujc02np"
allocate_public_ip = true
internet_max_bandwidth_out = 2
count = 3

// Create a PREPAID CVM instance
resource "tencentcloud_instance" "cvm_prepaid" {
instance_name = "cvm_prepaid"
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
system_disk_type = "CLOUD_PREMIUM"
system_disk_size = 50
hostname = "user"
project_id = 0
vpc_id = tencentcloud_vpc.app.id
subnet_id = tencentcloud_subnet.app.id
instance_charge_type = "PREPAID"
instance_charge_type_prepaid_period = 1
instance_charge_type_prepaid_renew_flag = "NOTIFY_AND_MANUAL_RENEW"
data_disks {
data_disk_type = "CLOUD_PREMIUM"
data_disk_size = 50
encrypt = false
}
force_delete = true
tags = {
tagKey = "tagValue"
}
}
```

Expand Down