» aws_elasticsearch_domain

» Example Usage

resource "aws_elasticsearch_domain" "es" {
  domain_name           = "tf-test"
  elasticsearch_version = "1.5"
  cluster_config {
    instance_type = "r3.large.elasticsearch"
  }

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

  access_policies = <<CONFIG
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": "es:*",
            "Principal": "*",
            "Effect": "Allow",
            "Condition": {
                "IpAddress": {"aws:SourceIp": ["66.193.100.22/32"]}
            }
        }
    ]
}
CONFIG

  snapshot_options {
    automated_snapshot_start_hour = 23
  }

  tags {
    Domain = "TestDomain"
  }
}

» Argument Reference

The following arguments are supported:

ebs_options supports the following attributes:

  • ebs_enabled - (Required) Whether EBS volumes are attached to data nodes in the domain
  • volume_type - (Optional) The type of EBS volumes attached to data nodes.
  • volume_size - The size of EBS volumes attached to data nodes (in GB). Required if ebs_enabled is set to true.
  • iops - (Optional) The baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the Provisioned IOPS EBS volume type.

encrypt_at_rest supports the following attributes:

  • enabled - (Required) Whether to enable encryption at rest. If the encrypt_at_rest block is not provided then this defaults to false.
  • kms_key_id - (Optional) The KMS key id to encrypt the Elasticsearch domain with. If not specified then it defaults to using the aws/es service KMS key.

cluster_config supports the following attributes:

vpc_options supports the following attributes:

AWS documentation: VPC Support for Amazon Elasticsearch Service Domains

  • security_group_ids - (Optional) List of VPC Security Group IDs to be applied to the Elasticsearch domain endpoints. If omitted, the default Security Group for the VPC will be used.
  • subnet_ids - (Required) List of VPC Subnet IDs for the Elasticsearch domain endpoints to be created in.

Security Groups and Subnets referenced in these attributes must all be within the same VPC; this determines what VPC the endpoints are created in.

snapshot_options supports the following attribute:

log_publishing_options supports the following attribute:

  • log_type - (Required) A type of Elasticsearch log. Valid values: INDEX_SLOW_LOGS, SEARCH_SLOW_LOGS
  • cloudwatch_log_group_arn - (Required) ARN of the Cloudwatch log group to which log needs to be published.
  • enabled - (Optional, Default: true) Specifies whether given log publishing option is enabled or not.

» Attributes Reference

The following attributes are exported:

  • arn - Amazon Resource Name (ARN) of the domain.
  • domain_id - Unique identifier for the domain.
  • endpoint - Domain-specific endpoint used to submit index, search, and data upload requests.
  • kibana_endpoint - Domain-specific endpoint for kibana without https scheme.
  • vpc_options.0.availability_zones - If the domain was created inside a VPC, the names of the availability zones the configured subnet_ids were created inside.
  • vpc_options.0.vpc_id - If the domain was created inside a VPC, the ID of the VPC.

» Import

ElasticSearch domains can be imported using the domain_name, e.g.

$ terraform import aws_elasticsearch_domain.example domain_name