-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for opensearch domains (#144)
* adding initial support for opensearch domains * Auto Format * Fix var validation * Updating outputs * Auto Format * Convert log options to dynamic blocks * Removing restricition that prevents dev single instance instances * Adding anonymous_iam_actions var/support * Auto Format * Adding support for additional policies * Fixing additional_policy_documents var type * Auto Format * Ading policy sid * Auto Format * source_policy_documents * Adding overrides for policy statements * Auto Format * Removing additional policy statements * Auto Format * update readme * deduplicate domain * terraform fmt * update tflint * Update elasticsearch_domain.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * add new example, revert to join("" to avoid type changes during this update. * Update elasticsearch_domain.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cleanup unused provider * update readme and docs * update readme --------- Co-authored-by: Steven Hopkins <steve@cloudposse.com> Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> Co-authored-by: Benjamin Smith <ben.smith.developer@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1285ccd
commit 9f8894c
Showing
10 changed files
with
468 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# | ||
# Elasticsearch Domain | ||
# | ||
|
||
resource "aws_elasticsearch_domain_policy" "default" { | ||
count = local.elasticsearch_enabled && (length(var.iam_authorizing_role_arns) > 0 || length(var.iam_role_arns) > 0) ? 1 : 0 | ||
domain_name = module.this.id | ||
access_policies = join("", data.aws_iam_policy_document.default[*].json) | ||
} | ||
|
||
resource "aws_elasticsearch_domain" "default" { | ||
count = local.elasticsearch_enabled ? 1 : 0 | ||
domain_name = module.this.id | ||
elasticsearch_version = var.elasticsearch_version | ||
|
||
advanced_options = var.advanced_options | ||
|
||
advanced_security_options { | ||
enabled = var.advanced_security_options_enabled | ||
internal_user_database_enabled = var.advanced_security_options_internal_user_database_enabled | ||
master_user_options { | ||
master_user_arn = var.advanced_security_options_master_user_arn | ||
master_user_name = var.advanced_security_options_master_user_name | ||
master_user_password = var.advanced_security_options_master_user_password | ||
} | ||
} | ||
|
||
ebs_options { | ||
ebs_enabled = var.ebs_volume_size > 0 ? true : false | ||
volume_size = var.ebs_volume_size | ||
volume_type = var.ebs_volume_type | ||
iops = var.ebs_iops | ||
throughput = var.ebs_throughput | ||
} | ||
|
||
encrypt_at_rest { | ||
enabled = var.encrypt_at_rest_enabled | ||
kms_key_id = var.encrypt_at_rest_kms_key_id | ||
} | ||
|
||
domain_endpoint_options { | ||
enforce_https = var.domain_endpoint_options_enforce_https | ||
tls_security_policy = var.domain_endpoint_options_tls_security_policy | ||
custom_endpoint_enabled = var.custom_endpoint_enabled | ||
custom_endpoint = var.custom_endpoint_enabled ? var.custom_endpoint : null | ||
custom_endpoint_certificate_arn = var.custom_endpoint_enabled ? var.custom_endpoint_certificate_arn : null | ||
} | ||
|
||
cluster_config { | ||
instance_count = var.instance_count | ||
instance_type = var.instance_type | ||
dedicated_master_enabled = var.dedicated_master_enabled | ||
dedicated_master_count = var.dedicated_master_enabled ? var.dedicated_master_count : null | ||
dedicated_master_type = var.dedicated_master_enabled ? var.dedicated_master_type : null | ||
zone_awareness_enabled = var.zone_awareness_enabled | ||
warm_enabled = var.warm_enabled | ||
warm_count = var.warm_enabled ? var.warm_count : null | ||
warm_type = var.warm_enabled ? var.warm_type : null | ||
|
||
dynamic "zone_awareness_config" { | ||
for_each = var.availability_zone_count > 1 && var.zone_awareness_enabled ? [true] : [] | ||
content { | ||
availability_zone_count = var.availability_zone_count | ||
} | ||
} | ||
|
||
dynamic "cold_storage_options" { | ||
for_each = var.cold_storage_enabled ? [true] : [] | ||
content { | ||
enabled = var.cold_storage_enabled | ||
} | ||
} | ||
} | ||
|
||
dynamic "auto_tune_options" { | ||
for_each = var.auto_tune.enabled ? [true] : [] | ||
content { | ||
desired_state = "ENABLED" | ||
rollback_on_disable = var.auto_tune.rollback_on_disable | ||
maintenance_schedule { | ||
# Required until https://github.com/hashicorp/terraform-provider-aws/issues/22239 would be resolved | ||
start_at = var.auto_tune.starting_time == null ? timeadd(timestamp(), "1h") : var.auto_tune.starting_time | ||
duration { | ||
value = var.auto_tune.duration | ||
unit = "HOURS" | ||
} | ||
cron_expression_for_recurrence = var.auto_tune.cron_schedule | ||
} | ||
} | ||
} | ||
|
||
node_to_node_encryption { | ||
enabled = var.node_to_node_encryption_enabled | ||
} | ||
|
||
dynamic "vpc_options" { | ||
for_each = var.vpc_enabled ? [true] : [] | ||
|
||
content { | ||
security_group_ids = var.create_security_group ? [join("", aws_security_group.default[*].id)] : var.security_groups | ||
subnet_ids = var.subnet_ids | ||
} | ||
} | ||
|
||
snapshot_options { | ||
automated_snapshot_start_hour = var.automated_snapshot_start_hour | ||
} | ||
|
||
dynamic "cognito_options" { | ||
for_each = var.cognito_authentication_enabled ? [true] : [] | ||
content { | ||
enabled = true | ||
user_pool_id = var.cognito_user_pool_id | ||
identity_pool_id = var.cognito_identity_pool_id | ||
role_arn = var.cognito_iam_role_arn | ||
} | ||
} | ||
|
||
log_publishing_options { | ||
enabled = var.log_publishing_index_enabled | ||
log_type = "INDEX_SLOW_LOGS" | ||
cloudwatch_log_group_arn = var.log_publishing_index_cloudwatch_log_group_arn | ||
} | ||
|
||
log_publishing_options { | ||
enabled = var.log_publishing_search_enabled | ||
log_type = "SEARCH_SLOW_LOGS" | ||
cloudwatch_log_group_arn = var.log_publishing_search_cloudwatch_log_group_arn | ||
} | ||
|
||
log_publishing_options { | ||
enabled = var.log_publishing_audit_enabled | ||
log_type = "AUDIT_LOGS" | ||
cloudwatch_log_group_arn = var.log_publishing_audit_cloudwatch_log_group_arn | ||
} | ||
|
||
log_publishing_options { | ||
enabled = var.log_publishing_application_enabled | ||
log_type = "ES_APPLICATION_LOGS" | ||
cloudwatch_log_group_arn = var.log_publishing_application_cloudwatch_log_group_arn | ||
} | ||
|
||
tags = module.this.tags | ||
|
||
depends_on = [aws_iam_service_linked_role.default] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
provider "aws" { | ||
region = "us-east-2" | ||
} | ||
|
||
module "opensearch" { | ||
source = "../../" | ||
namespace = "eg" | ||
stage = "dev" | ||
name = "es" | ||
dns_zone_id = "Z14EN2YD427LRQ" | ||
security_groups = ["sg-XXXXXXXXX", "sg-YYYYYYYY"] | ||
vpc_id = "vpc-XXXXXXXXX" | ||
subnet_ids = ["subnet-XXXXXXXXX", "subnet-YYYYYYYY"] | ||
zone_awareness_enabled = "true" | ||
aws_service_type = "opensearch" | ||
elasticsearch_version = "OpenSearch_2.9" | ||
instance_type = "t3.small.search" | ||
instance_count = 4 | ||
ebs_volume_size = 10 | ||
iam_role_arns = ["arn:aws:iam::XXXXXXXXX:role/ops", "arn:aws:iam::XXXXXXXXX:role/dev"] | ||
iam_actions = ["es:ESHttpGet", "es:ESHttpPut", "es:ESHttpPost"] | ||
encrypt_at_rest_enabled = "true" | ||
kibana_subdomain_name = "kibana-es" | ||
|
||
advanced_options = { | ||
"rest.action.multi.allow_explicit_index" = "true" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= 1.3" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 4.0" | ||
} | ||
} | ||
} |
Oops, something went wrong.