diff --git a/README.md b/README.md index 66d27b3..0ad74de 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,7 @@ Available targets: | 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\_enabled](#input\_advanced\_security\_options\_enabled) | AWS Elasticsearch Kibana enchanced security plugin enabling (forces new resource) | `bool` | `false` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 6df0fdc..419257f 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -42,6 +42,7 @@ | 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\_enabled](#input\_advanced\_security\_options\_enabled) | AWS Elasticsearch Kibana enchanced security plugin enabling (forces new resource) | `bool` | `false` | no | diff --git a/main.tf b/main.tf index ebf17c8..ef37bcf 100644 --- a/main.tf +++ b/main.tf @@ -289,9 +289,9 @@ data "aws_iam_policy_document" "default" { } resource "aws_elasticsearch_domain_policy" "default" { - count = module.this.enabled && (length(var.iam_authorizing_role_arns) > 0 || length(var.iam_role_arns) > 0) ? 1 : 0 + count = module.this.enabled && (length(var.iam_authorizing_role_arns) > 0 || length(var.iam_role_arns) > 0 || length(var.access_policies) > 0) ? 1 : 0 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)) } module "domain_hostname" { diff --git a/variables.tf b/variables.tf index 54b00d5..ad563f3 100644 --- a/variables.tf +++ b/variables.tf @@ -430,3 +430,12 @@ variable "auto_tune" { } } +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." + } +}