Skip to content

Commit 31116b6

Browse files
authored
Added elasticsearch permissions (#38)
* Added elasticsearch permissions * Fix style
1 parent fbf02a8 commit 31116b6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

aws/backing-services/elasticsearch.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ variable "ELASTICSEARCH_ENABLED" {
4747
description = "Set to false to prevent the module from creating any resources"
4848
}
4949

50+
variable "ELASTICSEARCH_PERMITTED_NODES" {
51+
type = "string"
52+
description = "Kops kubernetes nodes that are permitted to access elastic search (e.g. 'nodes', 'masters', 'both' or 'any')"
53+
default = "nodes"
54+
}
55+
56+
locals {
57+
arns = {
58+
masters = ["${module.kops_metadata.masters_role_arn}"]
59+
nodes = ["${module.kops_metadata.nodes_role_arn}"]
60+
both = ["${module.kops_metadata.masters_role_arn}", "${module.kops_metadata.nodes_role_arn}"]
61+
any = ["*"]
62+
}
63+
}
64+
5065
module "elasticsearch" {
5166
source = "git::https://github.com/cloudposse/terraform-aws-elasticsearch.git?ref=tags/0.1.1"
5267
namespace = "${var.namespace}"
@@ -60,7 +75,7 @@ module "elasticsearch" {
6075
elasticsearch_version = "${var.ELASTICSEARCH_VERSION}"
6176
instance_type = "${var.ELASTICSEARCH_INSTANCE_TYPE}"
6277
instance_count = "${var.ELASTICSEARCH_INSTANCE_COUNT}"
63-
iam_role_arns = ["${module.kops_metadata.nodes_role_arn}"]
78+
iam_role_arns = ["${local.arns[var.ELASTICSEARCH_PERMITTED_NODES]}"]
6479
iam_actions = ["${var.ELASTICSEARCH_IAM_ACTIONS}"]
6580
kibana_subdomain_name = "kibana-elasticsearch"
6681
ebs_volume_size = "${var.ELASTICSEARCH_EBS_VOLUME_SIZE}"

0 commit comments

Comments
 (0)