From 33075697daf3c4aac6598075f163f5a2bfa76680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Fri, 22 Feb 2019 16:53:05 +0800 Subject: [PATCH 01/11] feat(instance) Added the module of instance --- README.md | 42 +++++++++++++++++++++++++++ main.tf | 16 +++++++++++ modules/instance/README.md | 25 +++++++++++++++++ modules/instance/main.tf | 10 +++++++ modules/instance/outputs.tf | 3 ++ modules/instance/variables.tf | 49 ++++++++++++++++++++++++++++++++ outputs.tf | 1 + variables.tf | 53 +++++++++++++++++++++++++++++++++++ 8 files changed, 199 insertions(+) create mode 100644 main.tf create mode 100644 modules/instance/README.md create mode 100644 modules/instance/main.tf create mode 100644 modules/instance/outputs.tf create mode 100644 modules/instance/variables.tf create mode 100644 outputs.tf create mode 100644 variables.tf diff --git a/README.md b/README.md index d92adf5..f747e10 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,44 @@ # terraform-alicloud-elasticsearch-instance Terraform module which creates ElasticSearch Instances on Alibaba Cloud + +These types of resources are supported: + +* [Alicloud_elasticsearch_instance](https://www.terraform.io/docs/providers/alicloud/r/elasticsearch.html) + +Root module calls these modules which can also be used separately to create independent resources: + +* [instance](https://github.com/terraform-alicloud-modules/terraform-alicloud-elasticsearch-instance/tree/master/modules/instance) - creates Elasticsearch instance + +Usage +----- +You can use this in your terraform template with the following steps. + +1. Adding a module resource to your template, e.g. main.tf + + module "elasticsearch_instance" { + source = "alibaba/elasticsearch/alicloud" + vswitch_id = "vsw-012345678abcdef" + instance_charge_type = "PostPaid" + data_node_amount = "2" + data_node_spec = "elasticsearch.sn2ne.large" + data_node_disk_size = "20" + data_node_disk_type = "cloud_ssd" + password = "PasswordGmail@" + es_version = "5.5.3_with_X-Pack" + } + +2. Setting values for the following variables through environment variables: + + - ALICLOUD_ACCESS_KEY + - ALICLOUD_SECRET_KEY + - ALICLOUD_REGION + +Authors +------- +Created and maintained by Guangfan Qu(@guangfanqu guangfan.qu@gmail.com) + +Reference +--------- +* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud) +* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/) +* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html) \ No newline at end of file diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..b4bd331 --- /dev/null +++ b/main.tf @@ -0,0 +1,16 @@ +######################### +# Elasticsearch instance +######################### + +module "instance" { + source = "./modules/instance" + + instance_charge_type = "${var.instance_charge_type}" + data_node_amount = "${var.data_node_amount}" + data_node_spec = "${var.data_node_spec}" + data_node_disk_size = "${var.data_node_disk_size}" + data_node_disk_type = "${var.data_node_disk_type}" + vswitch_id = "${var.vswitch_id}" + password = "${var.password}" + es_version = "${var.es_version}" +} diff --git a/modules/instance/README.md b/modules/instance/README.md new file mode 100644 index 0000000..65982b2 --- /dev/null +++ b/modules/instance/README.md @@ -0,0 +1,25 @@ +# alicloud_elasticsearch_instance + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +|description | The description of instance. | string | instance id | no | +|instance_charge_type | Valid values are `PrePaid`, `PostPaid`. | string | `PostPaid` | yes | +|period | The duration that you will buy Elasticsearch instance (in month). It is valid when instance_charge_type is PrePaid. Valid values: [1~9], 12, 24, 36. | string | "1" | no | +|data_node_amount | The Elasticsearch cluster's data node quantity, between 2 and 50. | string | "" | yes | +|data_node_spec | The data node specifications of the Elasticsearch instance. | string | "" | yes | +|data_node_disk_size | The single data node storage space. An SSD disk, supports a maximum of 2048 GiB (2 TB). An ultra disk, supports a maximum of 5120 GiB (5 TB). If the data to be stored is larger than 2048 GiB, an ultra disk can only support the following data sizes (GiB): [2560, 3072, 3584, 4096, 4608, 5120]. | string | "" | yes | +|data_node_disk_type | The data node disk type. Supported values: `cloud_ssd`, `cloud_efficiency`. | string | "" | yes | +|vswitch_id | The ID of VSwitch. | string | "" | yes | +|password | The password of the instance. The password can be 8 to 32 characters in length and must contain three of the following conditions: uppercase letters, lowercase letters, numbers, and special characters (!@#$%^&*()_+-=). | string | "" | yes | +|version | Elasticsearch version. Supported values: `5.5.3_with_X-Pack` and `6.3_with_X-Pack`. | string | "" | yes | +|private_whitelist | Set the instance's IP whitelist in VPC network. | list | "" | no | +|kibana_whitelist | Set the Kibana's IP whitelist in internet network. | list | "" | no | +|master_node_spec | The dedicated master node spec. If specified, dedicated master node will be created. | string | "" | no | + +## Outputs + +| Name | Description | +|------|-------------| +| instance_id | the ID of Elasticsearch instance. | diff --git a/modules/instance/main.tf b/modules/instance/main.tf new file mode 100644 index 0000000..30ac854 --- /dev/null +++ b/modules/instance/main.tf @@ -0,0 +1,10 @@ +resource "alicloud_elasticsearch_instance" "instance" { + instance_charge_type = "${var.instance_charge_type}" + data_node_amount = "${var.data_node_amount}" + data_node_spec = "${var.data_node_spec}" + data_node_disk_size = "${var.data_node_disk_size}" + data_node_disk_type = "${var.data_node_disk_type}" + vswitch_id = "${var.vswitch_id}" + password = "${var.password}" + version = "${var.es_version}" +} diff --git a/modules/instance/outputs.tf b/modules/instance/outputs.tf new file mode 100644 index 0000000..d07367a --- /dev/null +++ b/modules/instance/outputs.tf @@ -0,0 +1,3 @@ +output "instance_id" { + value = "${alicloud_elasticsearch_instance.instance.id}" +} diff --git a/modules/instance/variables.tf b/modules/instance/variables.tf new file mode 100644 index 0000000..f3942f2 --- /dev/null +++ b/modules/instance/variables.tf @@ -0,0 +1,49 @@ +variable "instance_charge_type" { + description = "Valid values are PrePaid, PostPaid. Default to PostPaid" + default = "PostPaid" +} + +variable "period" { + description = "The duration that you will buy Elasticsearch instance (in month). It is valid when instance_charge_type is PrePaid. Valid values: [1~9], 12, 24, 36." + default = "1" +} + +variable "data_node_spec" { + description = "The data node specifications of the Elasticsearch instance." +} + +variable "data_node_amount" { + description = "The Elasticsearch cluster's data node quantity, between 2 and 50." +} + +variable "data_node_disk_size" { + description = "The single data node storage space." +} + +variable "data_node_disk_type" { + description = "The data node disk type. Supported values: cloud_ssd, cloud_efficiency." +} + +variable "es_version" { + description = "Elasticsearch version. Supported values: 5.5.3_with_X-Pack and 6.3_with_X-Pack." +} + +variable "vswitch_id" { + description = "The ID of VSwitch." +} + +variable "password" { + description = "The password of the instance." +} + +variable "private_whitelist" { + type = "list" + description = "Set the instance's IP whitelist in VPC network." + default = ["0.0.0.0/0"] +} + +variable "kibana_whitelist" { + type = "list" + description = "Set the Kibana's IP whitelist in internet network." + default = ["0.0.0.0/0"] +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/outputs.tf @@ -0,0 +1 @@ + diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..1f3a7b6 --- /dev/null +++ b/variables.tf @@ -0,0 +1,53 @@ +variable "instance_charge_type" { + default = "PostPaid" +} + +variable "description" { + default = "tf-testAccESResource" +} + +variable "period" { + default = "2" +} + +variable "data_node_spec" { + default = "elasticsearch.sn2ne.large" +} + +variable "data_node_amount" { + default = "3" +} + +variable "data_node_disk_size" { + default = "20" +} + +variable "data_node_disk_type" { + default = "cloud_ssd" +} + +variable "es_version" { + default = "6.3_with_X-Pack" +} + +variable "vswitch_id" { + default = "vsw-uf6hser75qrlib5idurat" +} + +variable "password" { + default = "MTest%12345" +} + +variable "private_whitelist" { + type = "list" + default = ["10.1.0.0/16", "10.0.0.0/16"] +} + +variable "kibana_whitelist" { + type = "list" + default = ["10.1.0.0/16", "10.0.0.0/16", "127.0.0.1"] +} + +variable "master_node_spec" { + default = "elasticsearch.sn2ne.xlarge" +} From f8522292395144666e746a978b03e2e0efd54382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Wed, 6 Mar 2019 19:40:11 +0800 Subject: [PATCH 02/11] Modified the module and outputs. --- README.md | 7 ++++--- example/main.tf | 15 +++++++++++++ example/outputs.tf | 3 +++ example/variables.tf | 50 ++++++++++++++++++++++++++++++++++++++++++++ main.tf | 7 +++---- outputs.tf | 4 +++- variables.tf | 41 ++++++++++++++++++------------------ 7 files changed, 99 insertions(+), 28 deletions(-) create mode 100644 example/main.tf create mode 100644 example/outputs.tf create mode 100644 example/variables.tf diff --git a/README.md b/README.md index f747e10..f7304ea 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ You can use this in your terraform template with the following steps. 1. Adding a module resource to your template, e.g. main.tf - module "elasticsearch_instance" { + resource "alicloud_elasticsearch_instance" "instance" { + count = 2 source = "alibaba/elasticsearch/alicloud" vswitch_id = "vsw-012345678abcdef" instance_charge_type = "PostPaid" @@ -24,8 +25,8 @@ You can use this in your terraform template with the following steps. data_node_disk_size = "20" data_node_disk_type = "cloud_ssd" password = "PasswordGmail@" - es_version = "5.5.3_with_X-Pack" - } + version = "5.5.3_with_X-Pack" + } 2. Setting values for the following variables through environment variables: diff --git a/example/main.tf b/example/main.tf new file mode 100644 index 0000000..f73967b --- /dev/null +++ b/example/main.tf @@ -0,0 +1,15 @@ +######################### +# Elasticsearch instance +######################### + +resource "alicloud_elasticsearch_instance" "instance" { + instance_charge_type = "${var.instance_charge_type}" + data_node_amount = "${var.data_node_amount}" + data_node_spec = "${var.data_node_spec}" + data_node_disk_size = "${var.data_node_disk_size}" + data_node_disk_type = "${var.data_node_disk_type}" + vswitch_id = "${var.vswitch_id}" + password = "${var.password}" + version = "${var.version}" + count = "${var.count}" +} diff --git a/example/outputs.tf b/example/outputs.tf new file mode 100644 index 0000000..2a4600f --- /dev/null +++ b/example/outputs.tf @@ -0,0 +1,3 @@ +output "elasticsearch_ids" { + value = "${join(",", alicloud_elasticsearch_instance.instance.*.id)}" +} diff --git a/example/variables.tf b/example/variables.tf new file mode 100644 index 0000000..c3f2267 --- /dev/null +++ b/example/variables.tf @@ -0,0 +1,50 @@ +variable "instance_charge_type" { + default = "PostPaid" +} + +variable "period" { + default = "1" +} + +variable "data_node_spec" { + default = "elasticsearch.sn2ne.large" +} + +variable "data_node_amount" { + default = "2" +} + +variable "data_node_disk_size" { + default = "20" +} + +variable "data_node_disk_type" { + default = "cloud_ssd" +} + +variable "version" { + default = "6.3_with_X-Pack" +} + +variable "vswitch_id" { + default = "vcwitch id" +} + +variable "password" { + default = "My@Test1Test" +} + +variable "private_whitelist" { + type = "list" + default = ["0.0.0.0/0"] +} + +variable "kibana_whitelist" { + type = "list" + default = ["0.0.0.0/0"] +} + +variable "count" { + description = "Instance count" + default = 1 +} diff --git a/main.tf b/main.tf index b4bd331..f73967b 100644 --- a/main.tf +++ b/main.tf @@ -2,9 +2,7 @@ # Elasticsearch instance ######################### -module "instance" { - source = "./modules/instance" - +resource "alicloud_elasticsearch_instance" "instance" { instance_charge_type = "${var.instance_charge_type}" data_node_amount = "${var.data_node_amount}" data_node_spec = "${var.data_node_spec}" @@ -12,5 +10,6 @@ module "instance" { data_node_disk_type = "${var.data_node_disk_type}" vswitch_id = "${var.vswitch_id}" password = "${var.password}" - es_version = "${var.es_version}" + version = "${var.version}" + count = "${var.count}" } diff --git a/outputs.tf b/outputs.tf index 8b13789..2a4600f 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1 +1,3 @@ - +output "elasticsearch_ids" { + value = "${join(",", alicloud_elasticsearch_instance.instance.*.id)}" +} diff --git a/variables.tf b/variables.tf index 1f3a7b6..7221c44 100644 --- a/variables.tf +++ b/variables.tf @@ -1,53 +1,54 @@ variable "instance_charge_type" { - default = "PostPaid" -} - -variable "description" { - default = "tf-testAccESResource" + description = "Valid values are PrePaid, PostPaid. Default to PostPaid" + default = "PostPaid" } variable "period" { - default = "2" + description = "The duration that you will buy Elasticsearch instance (in month). It is valid when instance_charge_type is PrePaid. Valid values: [1~9], 12, 24, 36." + default = "1" } variable "data_node_spec" { - default = "elasticsearch.sn2ne.large" + description = "The data node specifications of the Elasticsearch instance." } variable "data_node_amount" { - default = "3" + description = "The Elasticsearch cluster's data node quantity, between 2 and 50." } variable "data_node_disk_size" { - default = "20" + description = "The single data node storage space." } variable "data_node_disk_type" { - default = "cloud_ssd" + description = "The data node disk type. Supported values: cloud_ssd, cloud_efficiency." } -variable "es_version" { - default = "6.3_with_X-Pack" +variable "version" { + description = "Elasticsearch version. Supported values: 5.5.3_with_X-Pack and 6.3_with_X-Pack." } variable "vswitch_id" { - default = "vsw-uf6hser75qrlib5idurat" + description = "The ID of VSwitch." } variable "password" { - default = "MTest%12345" + description = "The password of the instance." } variable "private_whitelist" { - type = "list" - default = ["10.1.0.0/16", "10.0.0.0/16"] + type = "list" + description = "Set the instance's IP whitelist in VPC network." + default = ["0.0.0.0/0"] } variable "kibana_whitelist" { - type = "list" - default = ["10.1.0.0/16", "10.0.0.0/16", "127.0.0.1"] + type = "list" + description = "Set the Kibana's IP whitelist in internet network." + default = ["0.0.0.0/0"] } -variable "master_node_spec" { - default = "elasticsearch.sn2ne.xlarge" +variable "count" { + description = "Instance count" + default = 1 } From d786a84c134a8c4b29880f92db24c1b851318c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Wed, 6 Mar 2019 19:42:02 +0800 Subject: [PATCH 03/11] Removed the module directory. --- modules/instance/README.md | 25 ------------------ modules/instance/main.tf | 10 ------- modules/instance/outputs.tf | 3 --- modules/instance/variables.tf | 49 ----------------------------------- 4 files changed, 87 deletions(-) delete mode 100644 modules/instance/README.md delete mode 100644 modules/instance/main.tf delete mode 100644 modules/instance/outputs.tf delete mode 100644 modules/instance/variables.tf diff --git a/modules/instance/README.md b/modules/instance/README.md deleted file mode 100644 index 65982b2..0000000 --- a/modules/instance/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# alicloud_elasticsearch_instance - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -|description | The description of instance. | string | instance id | no | -|instance_charge_type | Valid values are `PrePaid`, `PostPaid`. | string | `PostPaid` | yes | -|period | The duration that you will buy Elasticsearch instance (in month). It is valid when instance_charge_type is PrePaid. Valid values: [1~9], 12, 24, 36. | string | "1" | no | -|data_node_amount | The Elasticsearch cluster's data node quantity, between 2 and 50. | string | "" | yes | -|data_node_spec | The data node specifications of the Elasticsearch instance. | string | "" | yes | -|data_node_disk_size | The single data node storage space. An SSD disk, supports a maximum of 2048 GiB (2 TB). An ultra disk, supports a maximum of 5120 GiB (5 TB). If the data to be stored is larger than 2048 GiB, an ultra disk can only support the following data sizes (GiB): [2560, 3072, 3584, 4096, 4608, 5120]. | string | "" | yes | -|data_node_disk_type | The data node disk type. Supported values: `cloud_ssd`, `cloud_efficiency`. | string | "" | yes | -|vswitch_id | The ID of VSwitch. | string | "" | yes | -|password | The password of the instance. The password can be 8 to 32 characters in length and must contain three of the following conditions: uppercase letters, lowercase letters, numbers, and special characters (!@#$%^&*()_+-=). | string | "" | yes | -|version | Elasticsearch version. Supported values: `5.5.3_with_X-Pack` and `6.3_with_X-Pack`. | string | "" | yes | -|private_whitelist | Set the instance's IP whitelist in VPC network. | list | "" | no | -|kibana_whitelist | Set the Kibana's IP whitelist in internet network. | list | "" | no | -|master_node_spec | The dedicated master node spec. If specified, dedicated master node will be created. | string | "" | no | - -## Outputs - -| Name | Description | -|------|-------------| -| instance_id | the ID of Elasticsearch instance. | diff --git a/modules/instance/main.tf b/modules/instance/main.tf deleted file mode 100644 index 30ac854..0000000 --- a/modules/instance/main.tf +++ /dev/null @@ -1,10 +0,0 @@ -resource "alicloud_elasticsearch_instance" "instance" { - instance_charge_type = "${var.instance_charge_type}" - data_node_amount = "${var.data_node_amount}" - data_node_spec = "${var.data_node_spec}" - data_node_disk_size = "${var.data_node_disk_size}" - data_node_disk_type = "${var.data_node_disk_type}" - vswitch_id = "${var.vswitch_id}" - password = "${var.password}" - version = "${var.es_version}" -} diff --git a/modules/instance/outputs.tf b/modules/instance/outputs.tf deleted file mode 100644 index d07367a..0000000 --- a/modules/instance/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "instance_id" { - value = "${alicloud_elasticsearch_instance.instance.id}" -} diff --git a/modules/instance/variables.tf b/modules/instance/variables.tf deleted file mode 100644 index f3942f2..0000000 --- a/modules/instance/variables.tf +++ /dev/null @@ -1,49 +0,0 @@ -variable "instance_charge_type" { - description = "Valid values are PrePaid, PostPaid. Default to PostPaid" - default = "PostPaid" -} - -variable "period" { - description = "The duration that you will buy Elasticsearch instance (in month). It is valid when instance_charge_type is PrePaid. Valid values: [1~9], 12, 24, 36." - default = "1" -} - -variable "data_node_spec" { - description = "The data node specifications of the Elasticsearch instance." -} - -variable "data_node_amount" { - description = "The Elasticsearch cluster's data node quantity, between 2 and 50." -} - -variable "data_node_disk_size" { - description = "The single data node storage space." -} - -variable "data_node_disk_type" { - description = "The data node disk type. Supported values: cloud_ssd, cloud_efficiency." -} - -variable "es_version" { - description = "Elasticsearch version. Supported values: 5.5.3_with_X-Pack and 6.3_with_X-Pack." -} - -variable "vswitch_id" { - description = "The ID of VSwitch." -} - -variable "password" { - description = "The password of the instance." -} - -variable "private_whitelist" { - type = "list" - description = "Set the instance's IP whitelist in VPC network." - default = ["0.0.0.0/0"] -} - -variable "kibana_whitelist" { - type = "list" - description = "Set the Kibana's IP whitelist in internet network." - default = ["0.0.0.0/0"] -} From 68ba7f3bee5881f330dea19d9ea0c2569275f188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Wed, 6 Mar 2019 20:38:50 +0800 Subject: [PATCH 04/11] Modified the README.md --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7304ea..7072aa7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ You can use this in your terraform template with the following steps. resource "alicloud_elasticsearch_instance" "instance" { count = 2 - source = "alibaba/elasticsearch/alicloud" + source = "terraform-alicloud-modules/elasticsearch-instance/alicloud" vswitch_id = "vsw-012345678abcdef" instance_charge_type = "PostPaid" data_node_amount = "2" @@ -34,6 +34,32 @@ You can use this in your terraform template with the following steps. - ALICLOUD_SECRET_KEY - ALICLOUD_REGION +# alicloud_elasticsearch_instance + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +|description | The description of instance. | string | instance id | no | +|instance_charge_type | Valid values are `PrePaid`, `PostPaid`. | string | `PostPaid` | yes | +|period | The duration that you will buy Elasticsearch instance (in month). It is valid when instance_charge_type is PrePaid. Valid values: [1~9], 12, 24, 36. | string | "1" | no | +|data_node_amount | The Elasticsearch cluster's data node quantity, between 2 and 50. | string | "" | yes | +|data_node_spec | The data node specifications of the Elasticsearch instance. | string | "" | yes | +|data_node_disk_size | The single data node storage space. An SSD disk, supports a maximum of 2048 GiB (2 TB). An ultra disk, supports a maximum of 5120 GiB (5 TB). If the data to be stored is larger than 2048 GiB, an ultra disk can only support the following data sizes (GiB): [2560, 3072, 3584, 4096, 4608, 5120]. | string | "" | yes | +|data_node_disk_type | The data node disk type. Supported values: `cloud_ssd`, `cloud_efficiency`. | string | "" | yes | +|vswitch_id | The ID of VSwitch. | string | "" | yes | +|password | The password of the instance. The password can be 8 to 32 characters in length and must contain three of the following conditions: uppercase letters, lowercase letters, numbers, and special characters (!@#$%^&*()_+-=). | string | "" | yes | +|version | Elasticsearch version. Supported values: `5.5.3_with_X-Pack` and `6.3_with_X-Pack`. | string | "" | yes | +|private_whitelist | Set the instance's IP whitelist in VPC network. | list | "" | no | +|kibana_whitelist | Set the Kibana's IP whitelist in internet network. | list | "" | no | +|master_node_spec | The dedicated master node spec. If specified, dedicated master node will be created. | string | "" | no | + +## Outputs + +| Name | Description | +|------|-------------| +| instance_ids | the IDs of Elasticsearch instance. | + Authors ------- Created and maintained by Guangfan Qu(@guangfanqu guangfan.qu@gmail.com) From 9e543672c7460a4a5b43005b4d15e507749468a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Wed, 6 Mar 2019 20:50:52 +0800 Subject: [PATCH 05/11] Added the kibana and private whitelist in main.tf --- example/main.tf | 4 +++- example/variables.tf | 2 +- main.tf | 4 +++- variables.tf | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/example/main.tf b/example/main.tf index f73967b..182fccb 100644 --- a/example/main.tf +++ b/example/main.tf @@ -11,5 +11,7 @@ resource "alicloud_elasticsearch_instance" "instance" { vswitch_id = "${var.vswitch_id}" password = "${var.password}" version = "${var.version}" - count = "${var.count}" + count = "${var.number_of_instance}" + private_whitelist = "${var.private_whitelist}" + kibana_whitelist = "${var.kibana_whitelist}" } diff --git a/example/variables.tf b/example/variables.tf index c3f2267..6d6f2f1 100644 --- a/example/variables.tf +++ b/example/variables.tf @@ -44,7 +44,7 @@ variable "kibana_whitelist" { default = ["0.0.0.0/0"] } -variable "count" { +variable "number_of_instance" { description = "Instance count" default = 1 } diff --git a/main.tf b/main.tf index f73967b..182fccb 100644 --- a/main.tf +++ b/main.tf @@ -11,5 +11,7 @@ resource "alicloud_elasticsearch_instance" "instance" { vswitch_id = "${var.vswitch_id}" password = "${var.password}" version = "${var.version}" - count = "${var.count}" + count = "${var.number_of_instance}" + private_whitelist = "${var.private_whitelist}" + kibana_whitelist = "${var.kibana_whitelist}" } diff --git a/variables.tf b/variables.tf index 7221c44..825b298 100644 --- a/variables.tf +++ b/variables.tf @@ -48,7 +48,7 @@ variable "kibana_whitelist" { default = ["0.0.0.0/0"] } -variable "count" { +variable "number_of_instance" { description = "Instance count" default = 1 } From 4f05af2c575618ce8ec7f1e11472c4d816076886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Wed, 6 Mar 2019 21:21:40 +0800 Subject: [PATCH 06/11] Modified the default value --- variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variables.tf b/variables.tf index 825b298..9f1894e 100644 --- a/variables.tf +++ b/variables.tf @@ -39,13 +39,13 @@ variable "password" { variable "private_whitelist" { type = "list" description = "Set the instance's IP whitelist in VPC network." - default = ["0.0.0.0/0"] + default = [""] } variable "kibana_whitelist" { type = "list" description = "Set the Kibana's IP whitelist in internet network." - default = ["0.0.0.0/0"] + default = [""] } variable "number_of_instance" { From 6406f2d602a068c0835bdbad3568ceff2be39681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Wed, 6 Mar 2019 23:01:24 +0800 Subject: [PATCH 07/11] Updated variables --- example/variables.tf | 4 ++-- variables.tf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/variables.tf b/example/variables.tf index 6d6f2f1..fe7a15f 100644 --- a/example/variables.tf +++ b/example/variables.tf @@ -27,11 +27,11 @@ variable "version" { } variable "vswitch_id" { - default = "vcwitch id" + default = "vswitch id" } variable "password" { - default = "My@Test1Test" + default = "your password" } variable "private_whitelist" { diff --git a/variables.tf b/variables.tf index 9f1894e..825b298 100644 --- a/variables.tf +++ b/variables.tf @@ -39,13 +39,13 @@ variable "password" { variable "private_whitelist" { type = "list" description = "Set the instance's IP whitelist in VPC network." - default = [""] + default = ["0.0.0.0/0"] } variable "kibana_whitelist" { type = "list" description = "Set the Kibana's IP whitelist in internet network." - default = [""] + default = ["0.0.0.0/0"] } variable "number_of_instance" { From d580391309a37c9bc06cc90de50bf5362da2f739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Thu, 7 Mar 2019 15:14:14 +0800 Subject: [PATCH 08/11] Modified modules and outputs. --- README.md | 29 +++++++++++++------------ example/main.tf | 26 +++++++++-------------- example/outputs.tf | 4 ++-- example/variables.tf | 50 -------------------------------------------- main.tf | 5 ++++- variables.tf | 12 ++++++++++- 6 files changed, 41 insertions(+), 85 deletions(-) delete mode 100644 example/variables.tf diff --git a/README.md b/README.md index 7072aa7..22bf560 100644 --- a/README.md +++ b/README.md @@ -15,17 +15,15 @@ You can use this in your terraform template with the following steps. 1. Adding a module resource to your template, e.g. main.tf - resource "alicloud_elasticsearch_instance" "instance" { - count = 2 - source = "terraform-alicloud-modules/elasticsearch-instance/alicloud" - vswitch_id = "vsw-012345678abcdef" - instance_charge_type = "PostPaid" - data_node_amount = "2" - data_node_spec = "elasticsearch.sn2ne.large" - data_node_disk_size = "20" - data_node_disk_type = "cloud_ssd" - password = "PasswordGmail@" - version = "5.5.3_with_X-Pack" + module "instance" { + source = "terraform-alicloud-modules/elasticsearch-instance/alicloud" + password = "Your password" + data_node_spec = "elasticsearch.sn2ne.large" + data_node_amount = "2" + data_node_disk_size = "20" + data_node_disk_type = "cloud_ssd" + es_version = "5.5.3_with_X-Pack" + vswitch_id = "vswitch id" } 2. Setting values for the following variables through environment variables: @@ -49,10 +47,11 @@ You can use this in your terraform template with the following steps. |data_node_disk_type | The data node disk type. Supported values: `cloud_ssd`, `cloud_efficiency`. | string | "" | yes | |vswitch_id | The ID of VSwitch. | string | "" | yes | |password | The password of the instance. The password can be 8 to 32 characters in length and must contain three of the following conditions: uppercase letters, lowercase letters, numbers, and special characters (!@#$%^&*()_+-=). | string | "" | yes | -|version | Elasticsearch version. Supported values: `5.5.3_with_X-Pack` and `6.3_with_X-Pack`. | string | "" | yes | -|private_whitelist | Set the instance's IP whitelist in VPC network. | list | "" | no | -|kibana_whitelist | Set the Kibana's IP whitelist in internet network. | list | "" | no | -|master_node_spec | The dedicated master node spec. If specified, dedicated master node will be created. | string | "" | no | +|es_version | Elasticsearch version. Supported values: `5.5.3_with_X-Pack` and `6.3_with_X-Pack`. | string | "" | yes | +|private_whitelist | Set the instance's IP whitelist in VPC network. | list | ["0.0.0.0/0"] | no | +|kibana_whitelist | Set the Kibana's IP whitelist in internet network. | list | ["0.0.0.0/0"] | no | +|master_node_spec | The dedicated master node spec. If specified, dedicated master node will be created. | string | 1 | no | +|number_of_instance | The amount of the Elasticsearch instances. | int | 1 | no | ## Outputs diff --git a/example/main.tf b/example/main.tf index 182fccb..9b6b71f 100644 --- a/example/main.tf +++ b/example/main.tf @@ -1,17 +1,11 @@ -######################### -# Elasticsearch instance -######################### - -resource "alicloud_elasticsearch_instance" "instance" { - instance_charge_type = "${var.instance_charge_type}" - data_node_amount = "${var.data_node_amount}" - data_node_spec = "${var.data_node_spec}" - data_node_disk_size = "${var.data_node_disk_size}" - data_node_disk_type = "${var.data_node_disk_type}" - vswitch_id = "${var.vswitch_id}" - password = "${var.password}" - version = "${var.version}" - count = "${var.number_of_instance}" - private_whitelist = "${var.private_whitelist}" - kibana_whitelist = "${var.kibana_whitelist}" +module "instance" { + source = "../" + password = "MyTest@1234" + data_node_spec = "elasticsearch.sn2ne.large" + data_node_amount = "2" + data_node_disk_size = "20" + data_node_disk_type = "cloud_ssd" + es_version = "5.5.3_with_X-Pack" + vswitch_id = "vsw-uf6hser75qrlib5idurat" + master_node_spec = "elasticsearch.sn2ne.large" } diff --git a/example/outputs.tf b/example/outputs.tf index 2a4600f..a749b53 100644 --- a/example/outputs.tf +++ b/example/outputs.tf @@ -1,3 +1,3 @@ output "elasticsearch_ids" { - value = "${join(",", alicloud_elasticsearch_instance.instance.*.id)}" -} + value = "${module.instance.elasticsearch_ids}" +} \ No newline at end of file diff --git a/example/variables.tf b/example/variables.tf deleted file mode 100644 index fe7a15f..0000000 --- a/example/variables.tf +++ /dev/null @@ -1,50 +0,0 @@ -variable "instance_charge_type" { - default = "PostPaid" -} - -variable "period" { - default = "1" -} - -variable "data_node_spec" { - default = "elasticsearch.sn2ne.large" -} - -variable "data_node_amount" { - default = "2" -} - -variable "data_node_disk_size" { - default = "20" -} - -variable "data_node_disk_type" { - default = "cloud_ssd" -} - -variable "version" { - default = "6.3_with_X-Pack" -} - -variable "vswitch_id" { - default = "vswitch id" -} - -variable "password" { - default = "your password" -} - -variable "private_whitelist" { - type = "list" - default = ["0.0.0.0/0"] -} - -variable "kibana_whitelist" { - type = "list" - default = ["0.0.0.0/0"] -} - -variable "number_of_instance" { - description = "Instance count" - default = 1 -} diff --git a/main.tf b/main.tf index 182fccb..49a2fcb 100644 --- a/main.tf +++ b/main.tf @@ -10,8 +10,11 @@ resource "alicloud_elasticsearch_instance" "instance" { data_node_disk_type = "${var.data_node_disk_type}" vswitch_id = "${var.vswitch_id}" password = "${var.password}" - version = "${var.version}" + version = "${var.es_version}" count = "${var.number_of_instance}" private_whitelist = "${var.private_whitelist}" kibana_whitelist = "${var.kibana_whitelist}" + description = "${var.description}" + master_node_spec = "${var.master_node_spec}" + period = "${var.period}" } diff --git a/variables.tf b/variables.tf index 825b298..fa1da11 100644 --- a/variables.tf +++ b/variables.tf @@ -24,7 +24,7 @@ variable "data_node_disk_type" { description = "The data node disk type. Supported values: cloud_ssd, cloud_efficiency." } -variable "version" { +variable "es_version" { description = "Elasticsearch version. Supported values: 5.5.3_with_X-Pack and 6.3_with_X-Pack." } @@ -48,6 +48,16 @@ variable "kibana_whitelist" { default = ["0.0.0.0/0"] } +variable "master_node_spec" { + description = "The master node specifications of the Elasticsearch instance." + default = "" +} + +variable "description" { + description = "The description of the Elasticsearch instance." + default = "" +} + variable "number_of_instance" { description = "Instance count" default = 1 From c23252752bace97f29f515251dfe37f1fc0126cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Thu, 7 Mar 2019 15:14:59 +0800 Subject: [PATCH 09/11] Modified modules and outputs. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22bf560..a862946 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ You can use this in your terraform template with the following steps. |es_version | Elasticsearch version. Supported values: `5.5.3_with_X-Pack` and `6.3_with_X-Pack`. | string | "" | yes | |private_whitelist | Set the instance's IP whitelist in VPC network. | list | ["0.0.0.0/0"] | no | |kibana_whitelist | Set the Kibana's IP whitelist in internet network. | list | ["0.0.0.0/0"] | no | -|master_node_spec | The dedicated master node spec. If specified, dedicated master node will be created. | string | 1 | no | +|master_node_spec | The dedicated master node spec. If specified, dedicated master node will be created. | string | "" | no | |number_of_instance | The amount of the Elasticsearch instances. | int | 1 | no | ## Outputs From 23fd4f028c8bb51950496dfe7ae31dc6dd7d9a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Thu, 7 Mar 2019 15:17:12 +0800 Subject: [PATCH 10/11] Modified the example main.tf --- example/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/main.tf b/example/main.tf index 9b6b71f..05c6ff6 100644 --- a/example/main.tf +++ b/example/main.tf @@ -1,11 +1,11 @@ module "instance" { source = "../" - password = "MyTest@1234" + password = "Your password" data_node_spec = "elasticsearch.sn2ne.large" data_node_amount = "2" data_node_disk_size = "20" data_node_disk_type = "cloud_ssd" es_version = "5.5.3_with_X-Pack" - vswitch_id = "vsw-uf6hser75qrlib5idurat" + vswitch_id = "vswitch id" master_node_spec = "elasticsearch.sn2ne.large" } From ae94a17fc2112a6a58441853689920fcf6b62d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B2=E5=B9=BF=E5=87=A1?= Date: Thu, 7 Mar 2019 15:22:52 +0800 Subject: [PATCH 11/11] Fmt the code. --- example/main.tf | 14 +++++++------- example/outputs.tf | 2 +- variables.tf | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/example/main.tf b/example/main.tf index 05c6ff6..c4e7102 100644 --- a/example/main.tf +++ b/example/main.tf @@ -1,11 +1,11 @@ module "instance" { - source = "../" - password = "Your password" - data_node_spec = "elasticsearch.sn2ne.large" - data_node_amount = "2" + source = "../" + password = "Your password" + data_node_spec = "elasticsearch.sn2ne.large" + data_node_amount = "2" data_node_disk_size = "20" data_node_disk_type = "cloud_ssd" - es_version = "5.5.3_with_X-Pack" - vswitch_id = "vswitch id" - master_node_spec = "elasticsearch.sn2ne.large" + es_version = "5.5.3_with_X-Pack" + vswitch_id = "vswitch id" + master_node_spec = "elasticsearch.sn2ne.large" } diff --git a/example/outputs.tf b/example/outputs.tf index a749b53..24e8b22 100644 --- a/example/outputs.tf +++ b/example/outputs.tf @@ -1,3 +1,3 @@ output "elasticsearch_ids" { value = "${module.instance.elasticsearch_ids}" -} \ No newline at end of file +} diff --git a/variables.tf b/variables.tf index fa1da11..d2237e9 100644 --- a/variables.tf +++ b/variables.tf @@ -50,12 +50,12 @@ variable "kibana_whitelist" { variable "master_node_spec" { description = "The master node specifications of the Elasticsearch instance." - default = "" + default = "" } variable "description" { description = "The description of the Elasticsearch instance." - default = "" + default = "" } variable "number_of_instance" {