forked from lgallard/terraform-aws-elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
42 lines (37 loc) · 1.33 KB
/
iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
resource "aws_cloudwatch_log_group" "es_cloudwatch_log_group" {
for_each = { for k, v in var.log_publishing_options :
k => v if var.enabled && lookup(v, "enabled", false) && lookup(v, "cloudwatch_log_group_name", null) != null
}
name = each.value["cloudwatch_log_group_name"]
retention_in_days = lookup(each.value, "log_publishing_options_retention", var.log_publishing_options_retention)
tags = merge(lookup(each.value, "tags", null), var.tags)
}
resource "aws_cloudwatch_log_resource_policy" "es_aws_cloudwatch_log_resource_policy" {
count = var.enabled && var.cloudwatch_log_enabled ? 1 : 0
policy_name = "${var.domain_name}-policy"
policy_document = <<CONFIG
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "es.amazonaws.com"
},
"Action": [
"logs:PutLogEvents",
"logs:PutLogEventsBatch",
"logs:CreateLogStream"
],
"Resource": "arn:aws:logs:*"
}
]
}
CONFIG
}
# Service-linked role to give Amazon ES permissions to access your VPC
resource "aws_iam_service_linked_role" "es" {
count = var.enabled && var.create_service_link_role ? 1 : 0
aws_service_name = "es.amazonaws.com"
description = "Service-linked role to give Amazon ES permissions to access your VPC"
}