From 2ef4d8a50bd595754ca993c4a7d2aea6da17ed19 Mon Sep 17 00:00:00 2001 From: lexwong Date: Mon, 23 Sep 2019 18:43:05 +0800 Subject: [PATCH] imporve(elasticsearch): update the module to the format of the new version. --- example/main.tf | 1 + example/outputs.tf | 3 ++- example/versions.tf | 4 ++++ main.tf | 35 +++++++++++++++++++++-------------- outputs.tf | 3 ++- variables.tf | 10 ++++++++-- versions.tf | 4 ++++ 7 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 example/versions.tf create mode 100644 versions.tf diff --git a/example/main.tf b/example/main.tf index c4e7102..895df6d 100644 --- a/example/main.tf +++ b/example/main.tf @@ -9,3 +9,4 @@ module "instance" { vswitch_id = "vswitch id" master_node_spec = "elasticsearch.sn2ne.large" } + diff --git a/example/outputs.tf b/example/outputs.tf index 24e8b22..578d36f 100644 --- a/example/outputs.tf +++ b/example/outputs.tf @@ -1,3 +1,4 @@ output "elasticsearch_ids" { - value = "${module.instance.elasticsearch_ids}" + value = module.instance.elasticsearch_ids } + diff --git a/example/versions.tf b/example/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/example/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/main.tf b/main.tf index 49a2fcb..d465f4f 100644 --- a/main.tf +++ b/main.tf @@ -1,20 +1,27 @@ +provider "alicloud" { + version = ">=1.56.0" + region = var.region != "" ? var.region : null + configuration_source = "terraform-alicloud-modules/elasticsearch-instance" +} + ######################### # 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.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}" + 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 + 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/outputs.tf b/outputs.tf index 2a4600f..0619127 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,3 +1,4 @@ output "elasticsearch_ids" { - value = "${join(",", alicloud_elasticsearch_instance.instance.*.id)}" + value = join(",", alicloud_elasticsearch_instance.instance.*.id) } + diff --git a/variables.tf b/variables.tf index d2237e9..b1c9a19 100644 --- a/variables.tf +++ b/variables.tf @@ -1,3 +1,8 @@ +variable "region" { + description = "The region used to launch this module resources." + default = "" +} + variable "instance_charge_type" { description = "Valid values are PrePaid, PostPaid. Default to PostPaid" default = "PostPaid" @@ -37,13 +42,13 @@ variable "password" { } variable "private_whitelist" { - type = "list" + type = list(string) description = "Set the instance's IP whitelist in VPC network." default = ["0.0.0.0/0"] } variable "kibana_whitelist" { - type = "list" + type = list(string) description = "Set the Kibana's IP whitelist in internet network." default = ["0.0.0.0/0"] } @@ -62,3 +67,4 @@ variable "number_of_instance" { description = "Instance count" default = 1 } + diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +}