diff --git a/README.md b/README.md
index ddad5fa..e1cf83f 100644
--- a/README.md
+++ b/README.md
@@ -158,6 +158,7 @@ Here are automated tests for the complete example using [bats](https://github.co
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
+| [access\_policies](#input\_access\_policies) | JSON string for the IAM policy document specifying the access policies for the domain. | `string` | `""` | no |
| [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
| [advanced\_options](#input\_advanced\_options) | Key-value string pairs to specify advanced configuration options | `map(string)` | `{}` | no |
| [advanced\_security\_options\_anonymous\_auth\_enabled](#input\_advanced\_security\_options\_anonymous\_auth\_enabled) | Whether Anonymous auth is enabled. Enables fine-grained access control on an existing domain | `bool` | `false` | no |
diff --git a/elasticsearch_domain.tf b/elasticsearch_domain.tf
index bb7be65..da318a4 100644
--- a/elasticsearch_domain.tf
+++ b/elasticsearch_domain.tf
@@ -3,9 +3,9 @@
#
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
+ count = local.elasticsearch_enabled && (length(var.iam_authorizing_role_arns) > 0 || length(var.iam_role_arns) > 0 || length(var.access_policies) > 0) ? 1 : 0
domain_name = length(var.elasticsearch_domain_name) > 0 ? var.elasticsearch_domain_name : module.this.id
- access_policies = join("", data.aws_iam_policy_document.default[*].json)
+ access_policies = coalesce(var.access_policies, join("", data.aws_iam_policy_document.default[*].json))
}
resource "aws_elasticsearch_domain" "default" {
diff --git a/variables.tf b/variables.tf
index 5367cb3..2698ba7 100644
--- a/variables.tf
+++ b/variables.tf
@@ -493,3 +493,13 @@ variable "advanced_security_options_anonymous_auth_enabled" {
default = false
description = "Whether Anonymous auth is enabled. Enables fine-grained access control on an existing domain"
}
+
+variable "access_policies" {
+ description = "JSON string for the IAM policy document specifying the access policies for the domain."
+ type = string
+ default = ""
+ validation {
+ condition = var.access_policies == "" || try(jsondecode(var.access_policies), null) != null
+ error_message = "The access_policies JSON string is not valid."
+ }
+}