Skip to content

Commit 4c1bb3b

Browse files
goruhabmbferreiracloudpossebot
authored
port #198 Parameterize access policies json for more flexibility (3rd try) (#210)
* parameterize access policies json for more flexibility * Auto Format * Pull changes from bmbferreira/terraform-aws-elasticsearch/tree/master --------- Co-authored-by: Bruno Ferreira <[email protected]> Co-authored-by: cloudpossebot <[email protected]>
1 parent 6b3f5f4 commit 4c1bb3b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Here are automated tests for the complete example using [bats](https://github.co
158158

159159
| Name | Description | Type | Default | Required |
160160
|------|-------------|------|---------|:--------:|
161+
| <a name="input_access_policies"></a> [access\_policies](#input\_access\_policies) | JSON string for the IAM policy document specifying the access policies for the domain. | `string` | `""` | no |
161162
| <a name="input_additional_tag_map"></a> [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`.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
162163
| <a name="input_advanced_options"></a> [advanced\_options](#input\_advanced\_options) | Key-value string pairs to specify advanced configuration options | `map(string)` | `{}` | no |
163164
| <a name="input_advanced_security_options_anonymous_auth_enabled"></a> [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 |

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 = length(var.elasticsearch_domain_name) > 0 ? var.elasticsearch_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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,13 @@ variable "advanced_security_options_anonymous_auth_enabled" {
493493
default = false
494494
description = "Whether Anonymous auth is enabled. Enables fine-grained access control on an existing domain"
495495
}
496+
497+
variable "access_policies" {
498+
description = "JSON string for the IAM policy document specifying the access policies for the domain."
499+
type = string
500+
default = ""
501+
validation {
502+
condition = var.access_policies == "" || try(jsondecode(var.access_policies), null) != null
503+
error_message = "The access_policies JSON string is not valid."
504+
}
505+
}

0 commit comments

Comments
 (0)