Skip to content

Commit f2882f7

Browse files
committed
parameterize access policies json for more flexibility
1 parent 2fed109 commit f2882f7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

elasticsearch_domain.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#
44

55
resource "aws_elasticsearch_domain_policy" "default" {
6-
count = local.elasticsearch_enabled && (length(var.iam_authorizing_role_arns) > 0 || length(var.iam_role_arns) > 0) ? 1 : 0
6+
count = local.elasticsearch_enabled && (length(var.iam_authorizing_role_arns) > 0 || length(var.iam_role_arns) > 0 || length(var.access_policies) > 0) ? 1 : 0
77
domain_name = module.this.id
8-
access_policies = join("", data.aws_iam_policy_document.default[*].json)
8+
access_policies = coalesce(var.access_policies, join("", data.aws_iam_policy_document.default[*].json))
99
}
1010

1111
resource "aws_elasticsearch_domain" "default" {

variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,12 @@ variable "auto_tune" {
448448
}
449449
}
450450

451+
variable "access_policies" {
452+
description = "JSON string for the IAM policy document specifying the access policies for the domain."
453+
type = string
454+
default = ""
455+
validation {
456+
condition = var.access_policies == "" || try(jsondecode(var.access_policies), null) != null
457+
error_message = "The access_policies JSON string is not valid."
458+
}
459+
}

0 commit comments

Comments
 (0)