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
139 changes: 120 additions & 19 deletions tencentcloud/resource_tc_elasticsearch_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,135 @@ Provides an elasticsearch instance resource.

Example Usage

Create a basic version of elasticsearch instance paid by the hour

```hcl
resource "tencentcloud_elasticsearch_instance" "foo" {
instance_name = "tf-test"
availability_zone = "ap-guangzhou-3"
version = "7.5.1"
vpc_id = var.vpc_id
subnet_id = var.subnet_id
password = "Test12345"
license_type = "basic"
data "tencentcloud_availability_zones_by_product" "availability_zone" {
product = "es"
}

resource "tencentcloud_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
name = "tf_es_vpc"
}

resource "tencentcloud_subnet" "subnet" {
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
name = "tf_es_subnet"
cidr_block = "10.0.1.0/24"
}

resource "tencentcloud_elasticsearch_instance" "example" {
instance_name = "tf_example_es"
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
version = "7.10.1"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
password = "Test12345"
license_type = "basic"
basic_security_type = 2

web_node_type_info {
node_num = 1
node_num = 1
node_type = "ES.S1.MEDIUM4"
}

node_info_list {
node_num = 2
node_type = "ES.S1.MEDIUM8"
encrypt = false
}

es_acl {
# black_list = [
# "9.9.9.9",
# "8.8.8.8",
# ]
white_list = [
"127.0.0.1",
]
}

tags = {
test = "test"
}
}
```

Create a basic version of elasticsearch instance for multi-availability zone deployment

```hcl
data "tencentcloud_availability_zones_by_product" "availability_zone" {
product = "es"
}

resource "tencentcloud_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
name = "tf_es_vpc"
}

resource "tencentcloud_subnet" "subnet" {
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
name = "tf_es_subnet"
cidr_block = "10.0.1.0/24"
}

resource "tencentcloud_subnet" "subnet_multi_zone" {
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.1.name
name = "tf_es_subnet"
cidr_block = "10.0.2.0/24"
}

resource "tencentcloud_elasticsearch_instance" "example_multi_zone" {
instance_name = "tf_example_es"
availability_zone = "-"
version = "7.10.1"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = "-"
password = "Test12345"
license_type = "basic"
basic_security_type = 2
deploy_mode = 1

multi_zone_infos {
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
subnet_id = tencentcloud_subnet.subnet.id
}

multi_zone_infos {
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.1.name
subnet_id = tencentcloud_subnet.subnet_multi_zone.id
}

web_node_type_info {
node_num = 1
node_type = "ES.S1.MEDIUM4"
encrypt = false
}

node_info_list {
type = "dedicatedMaster"
node_num = 3
node_type = "ES.S1.MEDIUM8"
encrypt = false
}

node_info_list {
type = "hotData"
node_num = 2
node_type = "ES.S1.MEDIUM8"
encrypt = false
}

es_acl {
black_list = [
"9.9.9.9",
"8.8.8.8",
]
# black_list = [
# "9.9.9.9",
# "8.8.8.8",
# ]
white_list = [
"0.0.0.0",
"127.0.0.1",
]
}

Expand Down Expand Up @@ -88,12 +189,12 @@ func resourceTencentCloudElasticsearchInstance() *schema.Resource {
Optional: true,
Default: "-",
ForceNew: true,
Description: "Availability zone. When create multi-az es, this parameter must be omitted.",
Description: "Availability zone. When create multi-az es, this parameter must be omitted or `-`.",
},
"version": {
Type: schema.TypeString,
Required: true,
Description: "Version of the instance. Valid values are `5.6.4`, `6.4.3`, `6.8.2` and `7.5.1`.",
Description: "Version of the instance. Valid values are `5.6.4`, `6.4.3`, `6.8.2`, `7.5.1` and `7.10.1`.",
},
"vpc_id": {
Type: schema.TypeString,
Expand All @@ -106,13 +207,13 @@ func resourceTencentCloudElasticsearchInstance() *schema.Resource {
Optional: true,
Default: "-",
ForceNew: true,
Description: "The ID of a VPC subnetwork. When create multi-az es, this parameter must be omitted.",
Description: "The ID of a VPC subnetwork. When create multi-az es, this parameter must be omitted or `-`.",
},
"password": {
Type: schema.TypeString,
Required: true,
Sensitive: true,
Description: "Password to an instance.",
Description: "Password to an instance, the password needs to be 8 to 16 characters, including at least two items ([a-z,A-Z], [0-9] and [-!@#$%&^*+=_:;,.?] special symbols.",
},
"charge_type": {
Type: schema.TypeString,
Expand Down
135 changes: 118 additions & 17 deletions website/docs/r/elasticsearch_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,34 @@ Provides an elasticsearch instance resource.

## Example Usage

### Create a basic version of elasticsearch instance paid by the hour

```hcl
resource "tencentcloud_elasticsearch_instance" "foo" {
instance_name = "tf-test"
availability_zone = "ap-guangzhou-3"
version = "7.5.1"
vpc_id = var.vpc_id
subnet_id = var.subnet_id
password = "Test12345"
license_type = "basic"
data "tencentcloud_availability_zones_by_product" "availability_zone" {
product = "es"
}

resource "tencentcloud_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
name = "tf_es_vpc"
}

resource "tencentcloud_subnet" "subnet" {
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
name = "tf_es_subnet"
cidr_block = "10.0.1.0/24"
}

resource "tencentcloud_elasticsearch_instance" "example" {
instance_name = "tf_example_es"
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
version = "7.10.1"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
password = "Test12345"
license_type = "basic"
basic_security_type = 2

web_node_type_info {
node_num = 1
Expand All @@ -30,17 +49,99 @@ resource "tencentcloud_elasticsearch_instance" "foo" {

node_info_list {
node_num = 2
node_type = "ES.S1.MEDIUM4"
node_type = "ES.S1.MEDIUM8"
encrypt = false
}

es_acl {
black_list = [
"9.9.9.9",
"8.8.8.8",
# black_list = [
# "9.9.9.9",
# "8.8.8.8",
# ]
white_list = [
"127.0.0.1",
]
}

tags = {
test = "test"
}
}
```

### Create a basic version of elasticsearch instance for multi-availability zone deployment

```hcl
data "tencentcloud_availability_zones_by_product" "availability_zone" {
product = "es"
}

resource "tencentcloud_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
name = "tf_es_vpc"
}

resource "tencentcloud_subnet" "subnet" {
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
name = "tf_es_subnet"
cidr_block = "10.0.1.0/24"
}

resource "tencentcloud_subnet" "subnet_multi_zone" {
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.1.name
name = "tf_es_subnet"
cidr_block = "10.0.2.0/24"
}

resource "tencentcloud_elasticsearch_instance" "example_multi_zone" {
instance_name = "tf_example_es"
availability_zone = "-"
version = "7.10.1"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = "-"
password = "Test12345"
license_type = "basic"
basic_security_type = 2
deploy_mode = 1

multi_zone_infos {
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.0.name
subnet_id = tencentcloud_subnet.subnet.id
}

multi_zone_infos {
availability_zone = data.tencentcloud_availability_zones_by_product.availability_zone.zones.1.name
subnet_id = tencentcloud_subnet.subnet_multi_zone.id
}

web_node_type_info {
node_num = 1
node_type = "ES.S1.MEDIUM4"
}

node_info_list {
type = "dedicatedMaster"
node_num = 3
node_type = "ES.S1.MEDIUM8"
encrypt = false
}

node_info_list {
type = "hotData"
node_num = 2
node_type = "ES.S1.MEDIUM8"
encrypt = false
}

es_acl {
# black_list = [
# "9.9.9.9",
# "8.8.8.8",
# ]
white_list = [
"0.0.0.0",
"127.0.0.1",
]
}

Expand All @@ -55,10 +156,10 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
The following arguments are supported:

* `node_info_list` - (Required, List) Node information list, which is used to describe the specification information of various types of nodes in the cluster, such as node type, node quantity, node specification, disk type, and disk size.
* `password` - (Required, String) Password to an instance.
* `version` - (Required, String) Version of the instance. Valid values are `5.6.4`, `6.4.3`, `6.8.2` and `7.5.1`.
* `password` - (Required, String) Password to an instance, the password needs to be 8 to 16 characters, including at least two items ([a-z,A-Z], [0-9] and [-!@#$%&^*+=_:;,.?] special symbols.
* `version` - (Required, String) Version of the instance. Valid values are `5.6.4`, `6.4.3`, `6.8.2`, `7.5.1` and `7.10.1`.
* `vpc_id` - (Required, String, ForceNew) The ID of a VPC network.
* `availability_zone` - (Optional, String, ForceNew) Availability zone. When create multi-az es, this parameter must be omitted.
* `availability_zone` - (Optional, String, ForceNew) Availability zone. When create multi-az es, this parameter must be omitted or `-`.
* `basic_security_type` - (Optional, Int) Whether to enable X-Pack security authentication in Basic Edition 6.8 and above. Valid values are `1` and `2`. `1` is disabled, `2` is enabled, and default value is `1`. Notice: this parameter is only take effect on `basic` license.
* `charge_period` - (Optional, Int, ForceNew) The tenancy of the prepaid instance, and uint is month. NOTE: it only works when charge_type is set to `PREPAID`.
* `charge_type` - (Optional, String, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`.
Expand All @@ -68,7 +169,7 @@ The following arguments are supported:
* `license_type` - (Optional, String) License type. Valid values are `oss`, `basic` and `platinum`. The default value is `platinum`.
* `multi_zone_infos` - (Optional, List, ForceNew) Details of AZs in multi-AZ deployment mode (which is required when deploy_mode is `1`).
* `renew_flag` - (Optional, String, ForceNew) When enabled, the instance will be renew automatically when it reach the end of the prepaid tenancy. Valid values are `RENEW_FLAG_AUTO` and `RENEW_FLAG_MANUAL`. NOTE: it only works when charge_type is set to `PREPAID`.
* `subnet_id` - (Optional, String, ForceNew) The ID of a VPC subnetwork. When create multi-az es, this parameter must be omitted.
* `subnet_id` - (Optional, String, ForceNew) The ID of a VPC subnetwork. When create multi-az es, this parameter must be omitted or `-`.
* `tags` - (Optional, Map) A mapping of tags to assign to the instance. For tag limits, please refer to [Use Limits](https://intl.cloud.tencent.com/document/product/651/13354).
* `web_node_type_info` - (Optional, List) Visual node configuration.

Expand Down