-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
35 lines (32 loc) · 869 Bytes
/
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
resource "aws_iam_role" "lambda" {
name = "${var.lambda_name}-lambda-role"
assume_role_policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : "sts:AssumeRole",
"Principal" : { "Service" : "lambda.amazonaws.com" }
}
]
})
}
resource "aws_iam_role_policy_attachment" "lambda" {
role = aws_iam_role.lambda.id
policy_arn = aws_iam_policy.lambda_cloudwatch.arn
}
resource "aws_iam_policy" "lambda_cloudwatch" {
name = "${var.lambda_name}-cloudwatch"
policy = data.aws_iam_policy_document.lambda_cloudwatch.json
}
data "aws_iam_policy_document" "lambda_cloudwatch" {
statement {
sid = "CreateCloudWatchLogs"
effect = "Allow"
actions = [
"logs:CreateLogStream",
"logs:PutLogEvents"
]
resources = ["arn:aws:logs:*:*:*"]
}
}