Skip to content

Commit 6f992d6

Browse files
committed
Update opensearch pod policy module name
1 parent 5ae8197 commit 6f992d6

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

modules/opensearch/main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ locals {
2222
static_domain_arn = "arn:${local.partition}:es:${local.region}:${local.account_id}:domain/${var.domain_name}"
2323

2424
tags = merge(var.tags, { terraform-aws-modules = "opensearch" })
25+
26+
name = "es-${var.application_name}"
2527
}
2628

2729
################################################################################
@@ -458,9 +460,9 @@ module "elasticsearch_secret" {
458460
resource_tags = var.tags
459461

460462
initial_value = jsonencode({
461-
ES_ENDPOINT = module.opensearch[0].domain_endpoint
462-
ES_DASHBOARD_ENDPOINT = module.opensearch[0].domain_dashboard_endpoint
463-
ES_DOMAIN_ID = module.opensearch[0].domain_id
464-
ES_PASSWORD = random_password.es.result
463+
ES_ENDPOINT = try(aws_opensearch_domain.this[0].endpoint, null)
464+
ES_DASHBOARD_ENDPOINT = try(aws_opensearch_domain.this[0].dashboard_endpoint, null)
465+
ES_DOMAIN_ID = try(aws_opensearch_domain.this[0].domain_id, null)
466+
ES_PASSWORD = var.advanced_security_options.master_user_options.master_user_password
465467
})
466468
}

opensearch.tf

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,6 @@ resource "random_password" "es" {
146146
special = false
147147
}
148148

149-
module "elasticsearch_secret" {
150-
count = var.elasticsearch_enabled ? 1 : 0
151-
source = "github.com/thoughtbot/terraform-aws-secrets//secret?ref=v0.4.0"
152-
153-
admin_principals = var.admin_principals
154-
description = "Elastisearch secrets for: ${local.name}"
155-
name = "${local.name}-secret"
156-
read_principals = var.read_principals
157-
resource_tags = var.tags
158-
159-
initial_value = jsonencode({
160-
ES_ENDPOINT = module.opensearch[0].domain_endpoint
161-
ES_DASHBOARD_ENDPOINT = module.opensearch[0].domain_dashboard_endpoint
162-
ES_DOMAIN_ID = module.opensearch[0].domain_id
163-
ES_PASSWORD = random_password.es.result
164-
})
165-
}
166-
167149
resource "aws_iam_role_policy_attachment" "test-attach" {
168150
count = var.elasticsearch_enabled ? 1 : 0
169151

@@ -173,7 +155,7 @@ resource "aws_iam_role_policy_attachment" "test-attach" {
173155
depends_on = [module.pod_policy]
174156
}
175157

176-
module "pod_policy" {
158+
module "es_pod_policy" {
177159
count = var.elasticsearch_enabled ? 1 : 0
178160
source = "github.com/thoughtbot/flightdeck//aws/service-account-policy?ref=v0.9.0"
179161

0 commit comments

Comments
 (0)