Skip to content

Commit 1542570

Browse files
author
Nikita Dugar
authored
Merge pull request #4 from clouddrove/CD-12
add new variables
2 parents 8adfc50 + 2eaa874 commit 1542570

File tree

5 files changed

+89
-63
lines changed

5 files changed

+89
-63
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
*.tfstate.backup
44
.terraform
55
.idea
6-
*.iml
6+
*.iml
7+
.terraform.tfstate.lock.info
8+

README.md

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Terraform AWS Elasticsearch
88
</h1>
99

10-
<p align="center" style="font-size: 1.2rem;">
10+
<p align="center" style="font-size: 1.2rem;">
1111
Terraform module to create an Elasticsearch resource on AWS.
1212
</p>
1313

@@ -38,7 +38,7 @@
3838
<hr>
3939

4040

41-
We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
41+
We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
4242

4343
This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
4444

@@ -49,9 +49,9 @@ We have [*fifty plus terraform modules*][terraform_modules]. A few of them are c
4949

5050
## Prerequisites
5151

52-
This module has a few dependencies:
52+
This module has a few dependencies:
5353

54-
- [Terraform 0.12](https://learn.hashicorp.com/terraform/getting-started/install.html)
54+
- [Terraform 0.13](https://learn.hashicorp.com/terraform/getting-started/install.html)
5555
- [Go](https://golang.org/doc/install)
5656
- [github.com/stretchr/testify/assert](https://github.com/stretchr/testify)
5757
- [github.com/gruntwork-io/terratest/modules/terraform](https://github.com/gruntwork-io/terratest)
@@ -139,52 +139,54 @@ Note: There are some type of instances which not support encryption and EBS opti
139139
## Inputs
140140

141141
| Name | Description | Type | Default | Required |
142-
|------|-------------|:----:|:-----:|:-----:|
143-
| advanced\_options | Key-value string pairs to specify advanced configuration options. | map(string) | `<map>` | no |
144-
| application | Application \(e.g. `cd` or `clouddrove`\). | string | `""` | no |
145-
| attributes | Additional attributes \(e.g. `1`\). | list | `<list>` | no |
146-
| automated\_snapshot\_start\_hour | Hour at which automated snapshots are taken, in UTC. | number | `"0"` | no |
147-
| availability\_zone\_count | Number of Availability Zones for the domain to use. | number | `"2"` | no |
148-
| dedicated\_master\_count | Number of dedicated master nodes in the cluster. | number | `"0"` | no |
149-
| dedicated\_master\_enabled | Indicates whether dedicated master nodes are enabled for the cluster. | bool | `"false"` | no |
150-
| dedicated\_master\_type | Instance type of the dedicated master nodes in the cluster. | string | `"t2.small.elasticsearch"` | no |
151-
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `"-"` | no |
152-
| dns\_enabled | Flag to control the dns\_enable. | bool | `"false"` | no |
153-
| dns\_zone\_id | Route53 DNS Zone ID to add hostname records for Elasticsearch domain and Kibana. | string | `""` | no |
154-
| domain\_name | Domain name. | string | `""` | no |
155-
| elasticsearch\_version | Version of Elasticsearch to deploy. | string | `"6.5"` | no |
156-
| enable\_iam\_service\_linked\_role | Whether to enabled service linked with role. | bool | `"false"` | no |
157-
| enable\_logs | enable logs | bool | `"true"` | no |
158-
| enabled | Set to false to prevent the module from creating any resources. | bool | `"true"` | no |
159-
| encrypt\_at\_rest\_enabled | Whether to enable encryption at rest. | bool | `"true"` | no |
160-
| encryption\_enabled | Whether to enable node-to-node encryption. | bool | `"false"` | no |
161-
| environment | Environment \(e.g. `prod`, `dev`, `staging`\). | string | `""` | no |
162-
| es\_hostname | The Host name of elasticserch. | string | `""` | no |
163-
| iam\_actions | List of actions to allow for the IAM roles, \_e.g.\_ `es:ESHttpGet`, `es:ESHttpPut`, `es:ESHttpPost`. | list(string) | `<list>` | no |
164-
| iam\_authorizing\_role\_arns | List of IAM role ARNs to permit to assume the Elasticsearch user role. | list(string) | `<list>` | no |
165-
| iam\_role\_arns | List of IAM role ARNs to permit access to the Elasticsearch domain. | list(string) | `<list>` | no |
166-
| instance\_count | Number of data nodes in the cluster. | number | `"4"` | no |
167-
| instance\_type | Elasticsearch instance type for data nodes in the cluster. | string | `"t2.small.elasticsearch"` | no |
168-
| iops | The baseline input/output \(I/O\) performance of EBS volumes attached to data nodes. Applicable only for the Provisioned IOPS EBS volume type. | number | `"0"` | no |
169-
| kibana\_hostname | The Host name of kibana. | string | `""` | no |
170-
| kms\_key\_id | The KMS key ID to encrypt the Elasticsearch domain with. If not specified, then it defaults to using the AWS/Elasticsearch service KMS key. | string | `""` | no |
171-
| label\_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
172-
| log\_publishing\_application\_cloudwatch\_log\_group\_arn | ARN of the CloudWatch log group to which log for ES\_APPLICATION\_LOGS needs to be published. | string | `""` | no |
173-
| log\_publishing\_application\_enabled | Specifies whether log publishing option for ES\_APPLICATION\_LOGS is enabled or not. | bool | `"false"` | no |
174-
| log\_publishing\_index\_cloudwatch\_log\_group\_arn | ARN of the CloudWatch log group to which log for INDEX\_SLOW\_LOGS needs to be published. | string | `""` | no |
175-
| log\_publishing\_index\_enabled | Specifies whether log publishing option for INDEX\_SLOW\_LOGS is enabled or not. | bool | `"false"` | no |
176-
| log\_publishing\_search\_cloudwatch\_log\_group\_arn | ARN of the CloudWatch log group to which log for SEARCH\_SLOW\_LOGS needs to be published. | string | `""` | no |
177-
| log\_publishing\_search\_enabled | Specifies whether log publishing option for SEARCH\_SLOW\_LOGS is enabled or not. | bool | `"false"` | no |
178-
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `"anmol@clouddrove.com"` | no |
179-
| name | Name \(e.g. `app` or `cluster`\). | string | `""` | no |
180-
| security\_group\_ids | Security Group IDs. | list(string) | n/a | yes |
181-
| subnet\_ids | Subnet IDs. | list(string) | n/a | yes |
182-
| tags | Additional tags \(e.g. map\(`BusinessUnit`,`XYZ`\). | map | `<map>` | no |
183-
| ttl | The TTL of the record to add to the DNS zone to complete certificate validation. | string | `"300"` | no |
184-
| type | Type of DNS records to create. | string | `"CNAME"` | no |
185-
| volume\_size | EBS volumes for data storage in GB. | number | `"0"` | no |
186-
| volume\_type | Storage type of EBS volumes. | string | `"gp2"` | no |
187-
| zone\_awareness\_enabled | Enable zone awareness for Elasticsearch cluster. | bool | `"false"` | no |
142+
|------|-------------|------|---------|:--------:|
143+
| advanced\_options | Key-value string pairs to specify advanced configuration options. | `map(string)` | `{}` | no |
144+
| application | Application (e.g. `cd` or `clouddrove`). | `string` | `""` | no |
145+
| attributes | Additional attributes (e.g. `1`). | `list` | `[]` | no |
146+
| automated\_snapshot\_start\_hour | Hour at which automated snapshots are taken, in UTC. | `number` | `0` | no |
147+
| availability\_zone\_count | Number of Availability Zones for the domain to use. | `number` | `2` | no |
148+
| dedicated\_master\_count | Number of dedicated master nodes in the cluster. | `number` | `0` | no |
149+
| dedicated\_master\_enabled | Indicates whether dedicated master nodes are enabled for the cluster. | `bool` | `false` | no |
150+
| dedicated\_master\_type | Instance type of the dedicated master nodes in the cluster. | `string` | `"t2.small.elasticsearch"` | no |
151+
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | `string` | `"-"` | no |
152+
| dns\_enabled | Flag to control the dns\_enable. | `bool` | `false` | no |
153+
| dns\_zone\_id | Route53 DNS Zone ID to add hostname records for Elasticsearch domain and Kibana. | `string` | `""` | no |
154+
| domain\_name | Domain name. | `string` | `""` | no |
155+
| elasticsearch\_version | Version of Elasticsearch to deploy. | `string` | `"6.5"` | no |
156+
| enable\_iam\_service\_linked\_role | Whether to enabled service linked with role. | `bool` | `false` | no |
157+
| enable\_logs | enable logs | `bool` | `true` | no |
158+
| enabled | Set to false to prevent the module from creating any resources. | `bool` | `true` | no |
159+
| encrypt\_at\_rest\_enabled | Whether to enable encryption at rest. | `bool` | `true` | no |
160+
| encryption\_enabled | Whether to enable node-to-node encryption. | `bool` | `false` | no |
161+
| enforce\_https | Whether or not to require HTTPS. | `bool` | `false` | no |
162+
| environment | Environment (e.g. `prod`, `dev`, `staging`). | `string` | `""` | no |
163+
| es\_hostname | The Host name of elasticserch. | `string` | `""` | no |
164+
| iam\_actions | List of actions to allow for the IAM roles, _e.g._ `es:ESHttpGet`, `es:ESHttpPut`, `es:ESHttpPost`. | `list(string)` | `[]` | no |
165+
| iam\_authorizing\_role\_arns | List of IAM role ARNs to permit to assume the Elasticsearch user role. | `list(string)` | `[]` | no |
166+
| iam\_role\_arns | List of IAM role ARNs to permit access to the Elasticsearch domain. | `list(string)` | `[]` | no |
167+
| instance\_count | Number of data nodes in the cluster. | `number` | `4` | no |
168+
| instance\_type | Elasticsearch instance type for data nodes in the cluster. | `string` | `"t2.small.elasticsearch"` | no |
169+
| iops | The baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the Provisioned IOPS EBS volume type. | `number` | `0` | no |
170+
| kibana\_hostname | The Host name of kibana. | `string` | `""` | no |
171+
| kms\_key\_id | The KMS key ID to encrypt the Elasticsearch domain with. If not specified, then it defaults to using the AWS/Elasticsearch service KMS key. | `string` | `""` | no |
172+
| label\_order | Label order, e.g. `name`,`application`. | `list` | `[]` | no |
173+
| log\_publishing\_application\_cloudwatch\_log\_group\_arn | ARN of the CloudWatch log group to which log for ES\_APPLICATION\_LOGS needs to be published. | `string` | `""` | no |
174+
| log\_publishing\_application\_enabled | Specifies whether log publishing option for ES\_APPLICATION\_LOGS is enabled or not. | `bool` | `false` | no |
175+
| log\_publishing\_index\_cloudwatch\_log\_group\_arn | ARN of the CloudWatch log group to which log for INDEX\_SLOW\_LOGS needs to be published. | `string` | `""` | no |
176+
| log\_publishing\_index\_enabled | Specifies whether log publishing option for INDEX\_SLOW\_LOGS is enabled or not. | `bool` | `false` | no |
177+
| log\_publishing\_search\_cloudwatch\_log\_group\_arn | ARN of the CloudWatch log group to which log for SEARCH\_SLOW\_LOGS needs to be published. | `string` | `""` | no |
178+
| log\_publishing\_search\_enabled | Specifies whether log publishing option for SEARCH\_SLOW\_LOGS is enabled or not. | `bool` | `false` | no |
179+
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | `string` | `"anmol@clouddrove.com"` | no |
180+
| name | Name (e.g. `app` or `cluster`). | `string` | `""` | no |
181+
| security\_group\_ids | Security Group IDs. | `list(string)` | n/a | yes |
182+
| subnet\_ids | Subnet IDs. | `list(string)` | n/a | yes |
183+
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | `map` | `{}` | no |
184+
| tls\_security\_policy | The name of the TLS security policy that needs to be applied to the HTTPS endpoint. | `any` | `null` | no |
185+
| ttl | The TTL of the record to add to the DNS zone to complete certificate validation. | `string` | `"300"` | no |
186+
| type | Type of DNS records to create. | `string` | `"CNAME"` | no |
187+
| volume\_size | EBS volumes for data storage in GB. | `number` | `0` | no |
188+
| volume\_type | Storage type of EBS volumes. | `string` | `"gp2"` | no |
189+
| zone\_awareness\_enabled | Enable zone awareness for Elasticsearch cluster. | `bool` | `false` | no |
188190

189191
## Outputs
190192

@@ -197,7 +199,7 @@ Note: There are some type of instances which not support encryption and EBS opti
197199

198200

199201
## Testing
200-
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
202+
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
201203

202204
You need to run the following command in the testing folder:
203205
```hcl
@@ -206,7 +208,7 @@ You need to run the following command in the testing folder:
206208

207209

208210

209-
## Feedback
211+
## Feedback
210212
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-elasticsearch/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).
211213

212214
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-elasticsearch)!

_example/single-node/example.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ module "elasticsearch" {
6060
log_publishing_search_cloudwatch_log_group_arn = true
6161
log_publishing_index_cloudwatch_log_group_arn = true
6262

63-
dns_enabled = true
64-
es_hostname = "es"
65-
kibana_hostname = "kibana"
66-
dns_zone_id = "Z1XJD7SSBKXLC1"
63+
enforce_https = true
64+
tls_security_policy = "Policy-Min-TLS-1-0-2019-07"
65+
dns_enabled = true
66+
es_hostname = "es"
67+
kibana_hostname = "kibana"
68+
dns_zone_id = "Z1XJD7SSBKXLC1"
6769

6870
advanced_options = {
6971
"rest.action.multi.allow_explicit_index" = "true"

main.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,24 @@ resource "aws_elasticsearch_domain" "default" {
132132
log_publishing_options {
133133
enabled = var.log_publishing_index_enabled
134134
log_type = "INDEX_SLOW_LOGS"
135-
cloudwatch_log_group_arn = join("", aws_cloudwatch_log_group.cloudwatch.*.arn)
135+
cloudwatch_log_group_arn = format("%s:*", join("", aws_cloudwatch_log_group.cloudwatch.*.arn))
136136
}
137137

138138
log_publishing_options {
139139
enabled = var.log_publishing_search_enabled
140140
log_type = "SEARCH_SLOW_LOGS"
141-
cloudwatch_log_group_arn = join("", aws_cloudwatch_log_group.cloudwatch.*.arn)
141+
cloudwatch_log_group_arn = format("%s:*", join("", aws_cloudwatch_log_group.cloudwatch.*.arn))
142142
}
143143

144144
log_publishing_options {
145145
enabled = var.log_publishing_application_enabled
146146
log_type = "ES_APPLICATION_LOGS"
147-
cloudwatch_log_group_arn = join("", aws_cloudwatch_log_group.cloudwatch.*.arn)
147+
cloudwatch_log_group_arn = format("%s:*", join("", aws_cloudwatch_log_group.cloudwatch.*.arn))
148+
}
149+
150+
domain_endpoint_options {
151+
enforce_https = var.enforce_https
152+
tls_security_policy = var.tls_security_policy
148153
}
149154

150155
tags = module.labels.tags
@@ -197,19 +202,24 @@ resource "aws_elasticsearch_domain" "single" {
197202
log_publishing_options {
198203
enabled = var.log_publishing_index_enabled
199204
log_type = "INDEX_SLOW_LOGS"
200-
cloudwatch_log_group_arn = join("", aws_cloudwatch_log_group.cloudwatch.*.arn)
205+
cloudwatch_log_group_arn = format("%s:*", join("", aws_cloudwatch_log_group.cloudwatch.*.arn))
201206
}
202207

203208
log_publishing_options {
204209
enabled = var.log_publishing_search_enabled
205210
log_type = "SEARCH_SLOW_LOGS"
206-
cloudwatch_log_group_arn = join("", aws_cloudwatch_log_group.cloudwatch.*.arn)
211+
cloudwatch_log_group_arn = format("%s:*", join("", aws_cloudwatch_log_group.cloudwatch.*.arn))
207212
}
208213

209214
log_publishing_options {
210215
enabled = var.log_publishing_application_enabled
211216
log_type = "ES_APPLICATION_LOGS"
212-
cloudwatch_log_group_arn = join("", aws_cloudwatch_log_group.cloudwatch.*.arn)
217+
cloudwatch_log_group_arn = format("%s:*", join("", aws_cloudwatch_log_group.cloudwatch.*.arn))
218+
}
219+
220+
domain_endpoint_options {
221+
enforce_https = var.enforce_https
222+
tls_security_policy = var.tls_security_policy
213223
}
214224

215225
tags = module.labels.tags

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,13 @@ variable "ttl" {
269269
description = "The TTL of the record to add to the DNS zone to complete certificate validation."
270270
}
271271

272+
variable "enforce_https" {
273+
type = bool
274+
default = false
275+
description = "Whether or not to require HTTPS."
276+
}
277+
278+
variable "tls_security_policy" {
279+
default = null
280+
description = "The name of the TLS security policy that needs to be applied to the HTTPS endpoint."
281+
}

0 commit comments

Comments
 (0)