diff --git a/README.md b/README.md index d8aaee9..fa2e1b9 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ The following table list the configurable parameters and their default values. | Name | Description | Default | | --- | --- | --- | | region | AWS Region | eu-west-1 | +| create_es | Should Elasticsearch cluster be created | true | | es_name | Domain name for Elasticsearch | cxcloud | | es_ver | Elasticsearch Version | 6.5 | | es_instance_type | Instance type for Elasticsearch | t2.small.elasticsearch | @@ -28,7 +29,6 @@ The following table list the configurable parameters and their default values. | s3_buffer_interval | S3 buffer interval | 60 | | s3_compression_format | S3 log compression format | GZIP | | es_index_name | Elasticsearch index name | cxcloud | -| es_type_name | Elasticsearch index type | logs | | es_buffering_size | Elasticsearch buffering size | 10 | | es_buffering_interval | Elasticsearch buffering interval | 60 | | s3_backup_mode | S3 backup mode | AllDocuments | @@ -48,17 +48,18 @@ The following table list the output variables ### Example -The following example show how the module can be used. In this example release 1.1.0 is used. +The following example show how the module can be used. In this example release 1.2.0 is used. -Note that release 1.1.0 requires terraform client ver 0.12 or above. Use release 1.0.0 for terraform versions below 0.12. +Note that release 1.2.0 requires terraform client ver 0.12 or above. Use release 1.0.0 for terraform versions below 0.12. ```console module "kinesis-firehose-elasticsearch" { - source = "github.com/cxcloud/terraform-kinesis-firehose-elasticsearch?ref=v1.1.0" + source = "github.com/cxcloud/terraform-kinesis-firehose-elasticsearch?ref=v1.2.0" region = "eu-west-1" + create_es = true es_name = "cxcloud" - es_ver = 6.5 - es_instance_type = "t2.small.elasticsearch" + es_ver = 7.9 + es_instance_type = "t3.small.elasticsearch" es_instance_count = 1 es_dedicated_master_enabled = false es_ebs_size = 35 @@ -66,12 +67,11 @@ module "kinesis-firehose-elasticsearch" { es_name_tag = "CX Cloud" es_whitelisted_ips = ["34.240.135.89/32"] stream_name = "cxcloud" - s3_bucket = "sandbox-logging" + s3_bucket = "cxcloud-logging" s3_buffer_size = 10 s3_buffer_interval = 60 s3_compression_format = "GZIP" es_index_name = "cxcloud" - es_type_name = "logs" es_buffering_size = 10 es_buffering_interval = 60 s3_backup_mode = "AllDocuments" diff --git a/main.tf b/main.tf index f0268ad..f27859f 100644 --- a/main.tf +++ b/main.tf @@ -3,6 +3,7 @@ data "aws_caller_identity" "current" {} # AWS Elasticsearch module "es" { source = "./modules/es" + create_es = var.create_es name = var.es_name region = var.region account_id = data.aws_caller_identity.current.account_id @@ -28,8 +29,8 @@ module "kinesis-firehose" { s3_buffer_size = var.s3_buffer_size s3_buffer_interval = var.s3_buffer_interval s3_compression_format = var.s3_compression_format + create_es_destination = var.create_es es_index_name = var.es_index_name - es_type_name = var.es_type_name es_buffering_size = var.es_buffering_size es_buffering_interval = var.es_buffering_interval s3_backup_mode = var.s3_backup_mode diff --git a/modules/es/main.tf b/modules/es/main.tf index 9d0286e..425f778 100644 --- a/modules/es/main.tf +++ b/modules/es/main.tf @@ -39,6 +39,7 @@ data "aws_iam_policy_document" "es_policy" { } resource "aws_elasticsearch_domain" "cxcloud" { + count = var.create_es ? 1 : 0 domain_name = var.name elasticsearch_version = var.es_ver diff --git a/modules/es/outputs.tf b/modules/es/outputs.tf index 8ad9a5d..cfceae9 100644 --- a/modules/es/outputs.tf +++ b/modules/es/outputs.tf @@ -1,19 +1,19 @@ output "arn" { - description = "ES ARN" - value = aws_elasticsearch_domain.cxcloud.arn + description = "Amazon Resource Name (ARN) of the domain" + value = var.create_es ? aws_elasticsearch_domain.cxcloud[0].arn : "" } output "endpoint" { - description = "ES Endpoint" - value = aws_elasticsearch_domain.cxcloud.endpoint + description = "Domain-specific endpoint used to submit index, search, and data upload requests" + value = var.create_es ? aws_elasticsearch_domain.cxcloud[0].endpoint : "" } output "domain_id" { - description = "ES ARN" - value = aws_elasticsearch_domain.cxcloud.domain_id + description = "Unique identifier for the domain" + value = var.create_es ? aws_elasticsearch_domain.cxcloud[0].domain_id : "" } output "domain_name" { - description = "ES ARN" - value = aws_elasticsearch_domain.cxcloud.domain_name + description = "The name of the Elasticsearch domain" + value = var.create_es ? aws_elasticsearch_domain.cxcloud[0].domain_name : "" } diff --git a/modules/es/variables.tf b/modules/es/variables.tf index e205998..fae9e35 100644 --- a/modules/es/variables.tf +++ b/modules/es/variables.tf @@ -1,3 +1,9 @@ +variable "create_es" { + type = bool + description = "Should ES cluster be created" + default = "true" +} + variable "name" { type = string description = "Domain name for Elasticsearch" @@ -17,7 +23,7 @@ variable "account_id" { variable "es_ver" { type = string description = "Elasticsearch Version" - default = 6.5 + default = 7.9 } variable "instance_type" { diff --git a/modules/kinesis-firehose/main.tf b/modules/kinesis-firehose/main.tf index a8d3dba..8614f42 100644 --- a/modules/kinesis-firehose/main.tf +++ b/modules/kinesis-firehose/main.tf @@ -24,8 +24,8 @@ POLICY } resource "aws_iam_policy" "firehose_delivery_policy" { - name = "firehose-delivery-policy" - path = "/" + name = "firehose-delivery-policy" + path = "/" description = "Kinesis Firehose delivery policy" policy = <