-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
49 lines (44 loc) · 1.02 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
43
44
45
46
47
48
49
/* role */
resource "aws_iam_role" "spotter" {
name = "terminationspotter-iam-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
/* policy */
data "aws_iam_policy_document" "terminationspotter" {
statement {
effect = "Allow"
actions = [
"logs:CreateLogStream",
"logs:CreateLogGroup",
"logs:PutLogEvents",
]
resources = [
"${aws_cloudwatch_log_group.spotter.arn}/*"
]
}
}
resource "aws_iam_policy" "terminationspotter" {
name = "terminationspotter-iam-policy"
path = "/"
description = "terminationspotter policy"
policy = data.aws_iam_policy_document.terminationspotter.json
}
/* policy attachment */
resource "aws_iam_role_policy_attachment" "terminationspotter" {
role = aws_iam_role.spotter.id
policy_arn = aws_iam_policy.terminationspotter.arn
}