@@ -15,15 +15,21 @@ data "aws_iam_session_context" "current" {
15
15
}
16
16
17
17
locals {
18
- account_id = try (data. aws_caller_identity . current [0 ]. account_id , " " )
19
- partition = try (data. aws_partition . current [0 ]. partition , " " )
20
- region = try (data. aws_region . current [0 ]. name , " " )
18
+ account_id = try (data. aws_caller_identity . current [0 ]. account_id , " " )
19
+ create_access_policy = var. create && var. create_access_policy && (length (var. access_policy_statements ) > 0 || length (var. access_policy_source_policy_documents ) > 0 || length (var. access_policy_override_policy_documents ) > 0 )
20
+ create_cloudwatch_log_groups = var. create && var. create_cloudwatch_log_groups
21
+ create_security_group = var. create && var. create_security_group && length (var. vpc_options ) > 0
22
+
23
+ partition = try (data. aws_partition . current [0 ]. partition , " " )
24
+ region = try (data. aws_region . current [0 ]. name , " " )
25
+
26
+ security_group_name = try (coalesce (var. security_group_name , var. domain_name ), " " )
21
27
22
28
static_domain_arn = " arn:${ local . partition } :es:${ local . region } :${ local . account_id } :domain/${ var . domain_name } "
23
29
24
30
tags = merge (var. tags , { terraform-aws-modules = " opensearch" })
25
31
26
- name = " es-${ var . application_name } "
32
+ name = " es-${ var . application_name } "
27
33
}
28
34
29
35
# ###############################################################################
@@ -206,10 +212,6 @@ resource "aws_opensearch_domain" "this" {
206
212
# Access Policy
207
213
# ###############################################################################
208
214
209
- locals {
210
- create_access_policy = var. create && var. create_access_policy && (length (var. access_policy_statements ) > 0 || length (var. access_policy_source_policy_documents ) > 0 || length (var. access_policy_override_policy_documents ) > 0 )
211
- }
212
-
213
215
resource "aws_opensearch_domain_policy" "this" {
214
216
count = var. create && var. enable_access_policy && (local. create_access_policy || var. access_policies != null ) ? 1 : 0
215
217
@@ -326,10 +328,6 @@ resource "aws_opensearch_outbound_connection" "this" {
326
328
# Cloudwatch Log Group
327
329
# ###############################################################################
328
330
329
- locals {
330
- create_cloudwatch_log_groups = var. create && var. create_cloudwatch_log_groups
331
- }
332
-
333
331
resource "aws_cloudwatch_log_group" "this" {
334
332
for_each = { for opt in var . log_publishing_options : opt . log_type => opt if try (opt. enabled , true ) && local . create_cloudwatch_log_groups }
335
333
@@ -385,11 +383,6 @@ resource "aws_cloudwatch_log_resource_policy" "this" {
385
383
# Security Group
386
384
# ###############################################################################
387
385
388
- locals {
389
- create_security_group = var. create && var. create_security_group && length (var. vpc_options ) > 0
390
- security_group_name = try (coalesce (var. security_group_name , var. domain_name ), " " )
391
- }
392
-
393
386
data "aws_subnet" "this" {
394
387
count = local. create_security_group ? 1 : 0
395
388
0 commit comments