Skip to content

Commit e8f9375

Browse files
author
mikatong
committed
support protocol
1 parent 861c7a0 commit e8f9375

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

tencentcloud/services/es/resource_tc_elasticsearch_instance.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ func ResourceTencentCloudElasticsearchInstance() *schema.Resource {
303303
},
304304
},
305305
},
306+
"protocol": {
307+
Type: schema.TypeString,
308+
Optional: true,
309+
Computed: true,
310+
Description: "Create an https cluster, default is http.",
311+
},
306312
// computed
307313
"elasticsearch_domain": {
308314
Type: schema.TypeString,
@@ -445,6 +451,9 @@ func resourceTencentCloudElasticsearchInstanceCreate(d *schema.ResourceData, met
445451
request.NodeInfoList = append(request.NodeInfoList, &info)
446452
}
447453
}
454+
if v, ok := d.GetOk("protocol"); ok {
455+
request.Protocol = helper.String(v.(string))
456+
}
448457
//internal version: replace reqTag begin, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
449458
//internal version: replace reqTag end, please do not modify this annotation and refrain from inserting any code between the beginning and end lines of the annotation.
450459
instanceId := ""
@@ -709,6 +718,7 @@ func resourceTencentCloudElasticsearchInstanceRead(d *schema.ResourceData, meta
709718
_ = d.Set("create_time", instance.CreateTime)
710719
_ = d.Set("kibana_public_access", instance.KibanaPublicAccess)
711720
_ = d.Set("kibana_private_access", instance.KibanaPrivateAccess)
721+
_ = d.Set("protocol", instance.Protocol)
712722

713723
multiZoneInfos := make([]map[string]interface{}, 0, len(instance.MultiZoneInfo))
714724
for _, item := range instance.MultiZoneInfo {
@@ -807,6 +817,14 @@ func resourceTencentCloudElasticsearchInstanceUpdate(d *schema.ResourceData, met
807817
client: meta.(tccommon.ProviderMeta).GetAPIV3Conn(),
808818
}
809819

820+
immutableArgs := []string{"protocol"}
821+
822+
for _, v := range immutableArgs {
823+
if d.HasChange(v) {
824+
return fmt.Errorf("argument `%s` cannot be changed", v)
825+
}
826+
}
827+
810828
d.Partial(true)
811829

812830
if d.HasChange("instance_name") {

tencentcloud/services/es/resource_tc_elasticsearch_instance_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,23 @@ func TestAccTencentCloudElasticsearchInstanceResource_publicAccess(t *testing.T)
233233
})
234234
}
235235

236+
func TestAccTencentCloudElasticsearchInstanceResource_https(t *testing.T) {
237+
resource.Test(t, resource.TestCase{
238+
PreCheck: func() { tcacctest.AccPreCheck(t) },
239+
Providers: tcacctest.AccProviders,
240+
CheckDestroy: testAccCheckElasticsearchInstanceDestroy,
241+
Steps: []resource.TestStep{
242+
{
243+
Config: testAccElasticsearchInstanceKibanaPublicAccessHttps,
244+
Check: resource.ComposeTestCheckFunc(
245+
testAccCheckElasticsearchInstanceExists("tencentcloud_elasticsearch_instance.es_kibana"),
246+
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.es_kibana", "protocol", "https"),
247+
),
248+
},
249+
},
250+
})
251+
}
252+
236253
func testAccCheckElasticsearchInstanceDestroy(s *terraform.State) error {
237254
logId := tccommon.GetLogId(tccommon.ContextNil)
238255
ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
@@ -526,3 +543,33 @@ resource "tencentcloud_elasticsearch_instance" "es_kibana" {
526543
}
527544
}
528545
`
546+
547+
const testAccElasticsearchInstanceKibanaPublicAccessHttps = tcacctest.DefaultEsVariables + `
548+
resource "tencentcloud_elasticsearch_instance" "es_kibana" {
549+
instance_name = "tf-ci-test-kibana"
550+
availability_zone = var.availability_zone
551+
version = "7.10.1"
552+
vpc_id = var.vpc_id
553+
subnet_id = var.subnet_id
554+
password = "Test1234"
555+
license_type = "basic"
556+
basic_security_type = 2
557+
public_access = "OPEN"
558+
protocol = "https"
559+
es_acl {
560+
white_list = [
561+
"127.0.0.2"
562+
]
563+
}
564+
es_public_acl {
565+
white_ip_list = [
566+
"127.0.0.2"
567+
]
568+
}
569+
570+
node_info_list {
571+
node_num = 2
572+
node_type = "ES.S1.MEDIUM4"
573+
}
574+
}
575+
`

website/docs/r/elasticsearch_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ The following arguments are supported:
177177
* `kibana_public_access` - (Optional, String) Kibana public network access status. Valid values are `OPEN` and `CLOSE`.
178178
* `license_type` - (Optional, String) License type. Valid values are `oss`, `basic` and `platinum`. The default value is `platinum`.
179179
* `multi_zone_infos` - (Optional, List, ForceNew) Details of AZs in multi-AZ deployment mode (which is required when deploy_mode is `1`).
180+
* `protocol` - (Optional, String) Create an https cluster, default is http.
180181
* `public_access` - (Optional, String) ES cluster public network access status. Valid values are `OPEN` and `CLOSE`. Cannot be changed at the same time as `es_acl`.
181182
* `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`.
182183
* `subnet_id` - (Optional, String, ForceNew) The ID of a VPC subnetwork. When create multi-az es, this parameter must be omitted or `-`.

0 commit comments

Comments
 (0)