-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiam_role.tf
55 lines (43 loc) · 1.12 KB
/
iam_role.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
50
51
52
53
54
55
resource "aws_iam_role" "cloud_trail" {
name = "cloudTrail-cloudWatch-role"
assume_role_policy = data.aws_iam_policy_document.cloud_trail_policy_document.json
}
data "aws_iam_policy_document" "cloud_trail_policy_document" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = [
"cloudtrail.amazonaws.com",
]
}
actions = ["sts:AssumeRole"]
}
}
resource "aws_iam_role_policy" "aws_iam_role_policy_cloudTrail_cloudWatch" {
name = "cloudTrail-cloudWatch-policy"
role = aws_iam_role.cloud_trail.id
policy = data.aws_iam_policy_document.aws_iam_role_policy_document.json
}
data "aws_iam_policy_document" "aws_iam_role_policy_document" {
statement {
sid = "AWSCloudTrailCreateLogStream2014110"
effect = "Allow"
actions = [
"logs:CreateLogStream"
]
resources = [
"${aws_cloudwatch_log_group.log_group.arn}:*"
]
}
statement {
sid = "AWSCloudTrailPutLogEvents20141101"
effect = "Allow"
actions = [
"logs:PutLogEvents"
]
resources = [
"${aws_cloudwatch_log_group.log_group.arn}:*"
]
}
}