generated from terraform-ibm-modules/terraform-ibm-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
51 lines (45 loc) · 1.93 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
##############################################################################
# Resource Group
##############################################################################
module "resource_group" {
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-resource-group.git?ref=v1.1.6"
# if an existing resource group is not set (null) create a new one using prefix
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
existing_resource_group_name = var.resource_group
}
##############################################################################
# Elasticsearch Instance
##############################################################################
module "icd_elasticsearch" {
source = "../../"
resource_group_id = module.resource_group.resource_group_id
name = "${var.prefix}-elasticsearch"
region = var.region
elasticsearch_version = var.elasticsearch_version
tags = var.resource_tags
access_tags = var.access_tags
service_credential_names = {
"elasticsearch_admin" : "Administrator",
"elasticsearch_operator" : "Operator",
"elasticsearch_viewer" : "Viewer",
"elasticsearch_editor" : "Editor",
}
}
# wait 60 secs to allow IAM credential access to kick in before configuring instance
# without the wait, you can intermittently get "Error 401 (Unauthorized)"
resource "time_sleep" "wait" {
depends_on = [module.icd_elasticsearch]
create_duration = "60s"
}
resource "elasticsearch_index" "test" {
depends_on = [time_sleep.wait]
name = "terraform-test"
number_of_shards = 1
number_of_replicas = 1
force_destroy = true
}
resource "elasticsearch_cluster_settings" "global" {
depends_on = [time_sleep.wait]
cluster_max_shards_per_node = 10
action_auto_create_index = "my-index-000001,index10,-index1*,+ind*"
}