Quantcast
Channel: lgallardo.com
Viewing all articles
Browse latest Browse all 111

Terraform module for Amazon Elasticsearch Service

$
0
0
terraform-aws-elasticsearch


I share here another Terraform module that I just published as open source, which allows you to create Amazon Elasticsearch Service clusters. The module is designed following the best practices and principles of the AWS Well-Architected Framework.

You can check the module terraform-aws-elasticsearch at the Terraform Registry or clone it from github

If you want to take a sneak of the module, I also left the README in this post:

terraform-aws-elasticsearch

Terraform module to create Amazon Elasticsearch Service clusters, following the Well-Architected Framework and best AWS practices.

Amazon Elasticsearch Service is a fully managed service that makes it easy to deploy, operate, and scale Elasticsearch clusters in the AWS Cloud. Elasticsearch is a popular open-source search and analytics engine for use cases such as log analytics, real-time application monitoring, and clickstream analysis. With Amazon ES, you get direct access to the Elasticsearch APIs; existing code and applications work seamlessly with the service.

Examples

Check the examples folder where you can see how to configure a public ES cluster, and another example showing how to set it with VPC options.

Usage

You can use this module to create your Amazon ES cluster by defining each parameters blocks as follows:

module "aws_es" {

  source = "git::https://github.com/lgallard/terraform-aws-elasticsearch.git"

  domain_name           = "elasticsearch_public"
  elasticsearch_version = "7.1"

  cluster_config = {
    dedicated_master_enabled = "true"
    instance_count           = "3"
    instance_type            = "r5.large.elasticsearch"
    zone_awareness_enabled   = "true"
    availability_zone_count  = "3"
  }

  ebs_options = {
    ebs_enabled = "true"
    volume_size = "25"
  }

  encrypt_at_rest = {
    enabled    = "true"
    kms_key_id = "alias/aws/es"
  }

  log_publishing_options = {
    enabled                  = "true"
    log_type                 = "INDEX_SLOW_LOGS"
  }

  advanced_options = {
    "rest.action.multi.allow_explicit_index" = "true"
  }

  node_to_node_encryption_enabled                = "true"
  snapshot_options_automated_snapshot_start_hour = "23"

  tags = {
    Owner = "sysops"
    env   = "dev"
  }

Note: You can also define the above ElasticSearch cluster using just the module variables. Instead of defining a cluster_config block (list of map), you can set each of the cluster_config_* variables, as shown below:

module "aws_es" {

  source = "git::https://github.com/lgallard/terraform-aws-elasticsearch.git"

  domain_name           = "elasticsearch_public"
  elasticsearch_version = "7.1"

  cluster_config_dedicated_master_enabled = true
  cluster_config_instance_count           = "3"
  cluster_config_instance_type            = "r5.large.elasticsearch"
  cluster_config_zone_awareness_enabled   = "true"
  cluster_config_availability_zone_count  = "3"

  ebs_options_ebs_enabled = true
  ebs_options_volume_size = "25"

  encrypt_at_rest_enabled    = true
  encrypt_at_rest_kms_key_id = "alias/aws/es"

  log_publishing_options_enabled  = true
  log_publishing_options_log_type = "INDEX_SLOW_LOGS"

  advanced_options = {
    "rest.action.multi.allow_explicit_index" = "true"
  }

  node_to_node_encryption_enabled                = "true"
  snapshot_options_automated_snapshot_start_hour = "23"

  tags = {
    Owner = "sysops"
    env   = "dev"
  }

Inputs

NameDescriptionTypeDefaultRequired
access_policiesIAM policy document specifying the access policies for the domainstring""no
advanced_optionsKey-value string pairs to specify advanced configuration options. Note that the values for these configuration options must be strings (wrapped in quotes) or they may be wrong and cause a perpetual diff, causing Terraform to want to recreate your Elasticsearch domain on every applymap(string){}no
cluster_configCluster configuration of the domainmap{}no
cluster_config_availability_zone_countNumber of Availability Zones for the domain to use withnumber3no
cluster_config_dedicated_master_countNumber of dedicated master nodes in the clusternumber3no
cluster_config_dedicated_master_enabledIndicates whether dedicated master nodes are enabled for the clusterbooltrueno
cluster_config_dedicated_master_typeInstance type of the dedicated master nodes in the clusterstring"r5.large.elasticsearch"no
cluster_config_instance_countNumber of instances in the clusternumber3no
cluster_config_instance_typeInstance type of data nodes in the clusterstring"r5.large.elasticsearch"no
cluster_config_zone_awareness_enabledIndicates whether zone awareness is enabled. To enable awareness with three Availability Zonesboolfalseno
cognito_optionsOptions for Amazon Cognito Authentication for Kibanamap{}no
cognito_options_enabledSpecifies whether Amazon Cognito authentication with Kibana is enabled or notboolfalseno
cognito_options_identity_pool_idID of the Cognito Identity Pool to usestring""no
cognito_options_role_arnARN of the IAM role that has the AmazonESCognitoAccess policy attachedstring""no
cognito_options_user_pool_idID of the Cognito User Pool to usestring""no
domain_nameName of the domainstringn/ayes
ebs_enabledWhether EBS volumes are attached to data nodes in the domainbooltrueno
ebs_optionsEBS related options, may be required based on chosen instance sizemap{}no
ebs_options_iopsThe baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the Provisioned IOPS EBS volume typenumber0no
ebs_options_volume_sizeThe size of EBS volumes attached to data nodes (in GB). Required if ebs_enabled is set to truenumber10no
ebs_options_volume_typeThe type of EBS volumes attached to data nodesstring"gp2"no
elasticsearch_versionThe version of Elasticsearch to deploy.string"7.1"no
encrypt_at_restEncrypt at rest options. Only available for certain instance typesmap{}no
encrypt_at_rest_enabledWhether to enable encryption at restbooltrueno
encrypt_at_rest_kms_key_idThe KMS key id to encrypt the Elasticsearch domain with. If not specified then it defaults to using the aws/es service KMS keystring"alias/aws/es"no
log_publishing_optionsOptions for publishing slow logs to CloudWatch Logsmap{}no
log_publishing_options_cloudwatch_log_group_arniARN of the Cloudwatch log group to which log needs to be publishedstring""no
log_publishing_options_enabledSpecifies whether given log publishing option is enabled or notbooltrueno
log_publishing_options_log_typeA type of Elasticsearch log. Valid values: INDEX_SLOW_LOGS, SEARCH_SLOW_LOGS, ES_APPLICATION_LOGSstring"INDEX\_SLOW\_LOGS"no
node_to_node_encryptionNode-to-node encryption optionsmap{}no
node_to_node_encryption_enabledWhether to enable node-to-node encryptionbooltrueno
snapshot_optionsSnapshot related optionsmap{}no
snapshot_options_automated_snapshot_start_hourHour during which the service takes an automated daily snapshot of the indices in the domainnumber0no
tagsA mapping of tags to assign to the resourcemap{}no
vpc_optionsVPC related options, see below. Adding or removing this configuration forces a new resourcemap{}no
vpc_options_security_group_idsList of VPC Security Group IDs to be applied to the Elasticsearch domain endpoints. If omitted, the default Security Group for the VPC will be usedlist[]no
vpc_options_subnet_idsList of VPC Subnet IDs for the Elasticsearch domain endpoints to be created inlist[]no

Outputs

NameDescription
arnAmazon Resource Name (ARN) of the domain
domain_idUnique identifier for the domain
endpointDomain-specific endpoint used to submit index, search, and data upload requests
kibana_endpointDomain-specific endpoint for kibana without https scheme
vpc_options_availability_zonesIf the domain was created inside a VPC, the names of the availability zones the configured subnet_ids were created inside
vpc_options_vpc_idIf the domain was created inside a VPC, the ID of the VPC

References


Viewing all articles
Browse latest Browse all 111

Trending Articles