forked from sbp-akamai/terraform-aws-mcaf-opensearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs.tf
49 lines (42 loc) · 1.5 KB
/
logs.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
43
44
45
46
47
48
49
resource "aws_cloudwatch_log_group" "cw_index" {
retention_in_days = var.cloudwatch_log_retention
name = "${var.cluster_name}/index_slow_logs"
kms_key_id = var.cloudwatch_log_kms_key_id
}
resource "aws_cloudwatch_log_group" "cw_search" {
retention_in_days = var.cloudwatch_log_retention
name = "${var.cluster_name}/search_slow_logs"
kms_key_id = var.cloudwatch_log_kms_key_id
}
resource "aws_cloudwatch_log_group" "cw_application" {
retention_in_days = var.cloudwatch_log_retention
name = "${var.cluster_name}/application_logs"
kms_key_id = var.cloudwatch_log_kms_key_id
}
resource "aws_cloudwatch_log_group" "cw_audit" {
retention_in_days = var.cloudwatch_log_retention
name = "${var.cluster_name}/audit_logs"
kms_key_id = var.cloudwatch_log_kms_key_id
}
data "aws_iam_policy_document" "cw_policy" {
statement {
actions = [
"logs:CreateLogStream",
"logs:PutLogEvents",
]
resources = [
"${aws_cloudwatch_log_group.cw_index.arn}:*",
"${aws_cloudwatch_log_group.cw_search.arn}:*",
"${aws_cloudwatch_log_group.cw_application.arn}:*",
"${aws_cloudwatch_log_group.cw_audit.arn}:*",
]
principals {
identifiers = ["es.amazonaws.com"]
type = "Service"
}
}
}
resource "aws_cloudwatch_log_resource_policy" "cw_resource_policy" {
policy_name = "${var.cluster_name}-cw-policy"
policy_document = data.aws_iam_policy_document.cw_policy.json
}