Skip to content

Commit 8a8acf4

Browse files
authored
Fix/adjust basic_security_type and license_type logic for the oss and basic edition instance (#1574)
* update dts mode * fix/adjust license_type because es offlined the oss type * 1.add changelog. 2.adjust scope of license_type. * update basic_security_type logic when license_type is the oss edition.
1 parent de6e301 commit 8a8acf4

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

.changelog/1574.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_elasticsearch_instance: adjust the scope of `license_type` field.
3+
```

tencentcloud/extension_elasticsearch.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ var ES_DEPLOY_MODE = []int{
4040
}
4141

4242
var ES_LICENSE_TYPE = []string{
43-
ES_LICENSE_TYPE_OSS,
4443
ES_LICENSE_TYPE_BASIC,
4544
ES_LICENSE_TYPE_PLATINUM,
4645
}

tencentcloud/resource_tc_elasticsearch_instance.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
1111
vpc_id = var.vpc_id
1212
subnet_id = var.subnet_id
1313
password = "Test12345"
14-
license_type = "oss"
14+
license_type = "basic"
1515
1616
web_node_type_info {
1717
node_num = 1
@@ -214,7 +214,7 @@ func resourceTencentCloudElasticsearchInstance() *schema.Resource {
214214
Optional: true,
215215
Default: ES_LICENSE_TYPE_PLATINUM,
216216
ValidateFunc: validateAllowedStringValue(ES_LICENSE_TYPE),
217-
Description: "License type. Valid values are `oss`, `basic` and `platinum`. The default value is `platinum`.",
217+
Description: "License type. Valid values are `basic` and `platinum`. The default value is `platinum`.",
218218
},
219219
"node_info_list": {
220220
Type: schema.TypeList,
@@ -267,7 +267,7 @@ func resourceTencentCloudElasticsearchInstance() *schema.Resource {
267267
Optional: true,
268268
Default: ES_BASIC_SECURITY_TYPE_OFF,
269269
ValidateFunc: validateAllowedIntValue(ES_BASIC_SECURITY_TYPE),
270-
Description: "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`.",
270+
Description: "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 for `basic edition.",
271271
},
272272
"tags": {
273273
Type: schema.TypeMap,
@@ -356,11 +356,15 @@ func resourceTencentCloudElasticsearchInstanceCreate(d *schema.ResourceData, met
356356
}
357357
}
358358
}
359+
var licenseType string
359360
if v, ok := d.GetOk("license_type"); ok {
360-
request.LicenseType = helper.String(v.(string))
361+
licenseType = v.(string)
362+
request.LicenseType = helper.String(licenseType)
361363
}
362364
if v, ok := d.GetOk("basic_security_type"); ok {
363-
request.BasicSecurityType = helper.IntUint64(v.(int))
365+
if licenseType == ES_LICENSE_TYPE_BASIC { // this field is only valid for the basic edition
366+
request.BasicSecurityType = helper.IntUint64(v.(int))
367+
}
364368
}
365369
if v, ok := d.GetOk("web_node_type_info"); ok {
366370
infos := v.([]interface{})
@@ -491,7 +495,10 @@ func resourceTencentCloudElasticsearchInstanceRead(d *schema.ResourceData, meta
491495
_ = d.Set("renew_flag", instance.RenewFlag)
492496
_ = d.Set("deploy_mode", instance.DeployMode)
493497
_ = d.Set("license_type", instance.LicenseType)
494-
_ = d.Set("basic_security_type", instance.SecurityType)
498+
licenseType := instance.LicenseType
499+
if licenseType != nil && *licenseType == ES_LICENSE_TYPE_BASIC { // this field is only valid for the basic edition
500+
_ = d.Set("basic_security_type", instance.SecurityType)
501+
}
495502
_ = d.Set("elasticsearch_domain", instance.EsDomain)
496503
_ = d.Set("elasticsearch_vip", instance.EsVip)
497504
_ = d.Set("elasticsearch_port", instance.EsPort)

tencentcloud/resource_tc_elasticsearch_instance_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestAccTencentCloudElasticsearchInstance_basic(t *testing.T) {
6060
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "version", "7.10.1"),
6161
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "vpc_id", defaultVpcId),
6262
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "subnet_id", defaultSubnetId),
63-
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "license_type", "oss"),
63+
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "license_type", "platinum"),
6464
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "web_node_type_info.#", "1"),
6565
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "web_node_type_info.0.node_num", "1"),
6666
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "web_node_type_info.0.node_type", "ES.S1.MEDIUM4"),
@@ -172,8 +172,7 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
172172
vpc_id = var.vpc_id
173173
subnet_id = var.subnet_id
174174
password = "Test1234"
175-
license_type = "oss"
176-
175+
177176
web_node_type_info {
178177
node_num = 1
179178
node_type = "ES.S1.MEDIUM4"

website/docs/r/elasticsearch_instance.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
2121
vpc_id = var.vpc_id
2222
subnet_id = var.subnet_id
2323
password = "Test12345"
24-
license_type = "oss"
24+
license_type = "basic"
2525
2626
web_node_type_info {
2727
node_num = 1
@@ -59,13 +59,13 @@ The following arguments are supported:
5959
* `version` - (Required, String) Version of the instance. Valid values are `5.6.4`, `6.4.3`, `6.8.2` and `7.5.1`.
6060
* `vpc_id` - (Required, String, ForceNew) The ID of a VPC network.
6161
* `availability_zone` - (Optional, String, ForceNew) Availability zone. When create multi-az es, this parameter must be omitted.
62-
* `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`.
62+
* `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 for `basic edition.
6363
* `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`.
6464
* `charge_type` - (Optional, String, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`.
6565
* `deploy_mode` - (Optional, Int, ForceNew) Cluster deployment mode. Valid values are `0` and `1`. `0` is single-AZ deployment, and `1` is multi-AZ deployment. Default value is `0`.
6666
* `es_acl` - (Optional, List) Kibana Access Control Configuration.
6767
* `instance_name` - (Optional, String) Name of the instance, which can contain 1 to 50 English letters, Chinese characters, digits, dashes(-), or underscores(_).
68-
* `license_type` - (Optional, String) License type. Valid values are `oss`, `basic` and `platinum`. The default value is `platinum`.
68+
* `license_type` - (Optional, String) License type. Valid values are `basic` and `platinum`. The default value is `platinum`.
6969
* `multi_zone_infos` - (Optional, List, ForceNew) Details of AZs in multi-AZ deployment mode (which is required when deploy_mode is `1`).
7070
* `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`.
7171
* `subnet_id` - (Optional, String, ForceNew) The ID of a VPC subnetwork. When create multi-az es, this parameter must be omitted.

0 commit comments

Comments
 (0)