Newer
Older
count = length(local.function_names)
name = "/aws/lambda/${local.function_names[count.index]}"
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
56
57
58
59
60
retention_in_days = var.log_retention
tags = local.common_tags
}
locals {
log_group_arns = aws_cloudwatch_log_group.lambda.*.arn
log_group_names = aws_cloudwatch_log_group.lambda.*.name
}
output "log_group_arns" {
description = "ARNs of the CloudWatch log groups for Lambda function invocations."
value = local.log_group_arns
}
output "log_group_names" {
description = "Names of the CloudWatch log groups for Lambda function invocations."
value = local.log_group_names
}
data "aws_iam_policy_document" "log" {
statement {
effect = "Allow"
actions = [
"logs:CreateLogStream",
"logs:PutLogEvents",
]
resources = [for arn in local.log_group_arns : "${arn}/*"]
}
}
locals {
log_policy_doc = data.aws_iam_policy_document.log.json
}
resource "aws_iam_policy" "log" {
name = "${local.module}-${local.env}-log"
policy = local.log_policy_doc
tags = local.common_tags
}
locals {
log_policy_arn = aws_iam_policy.log.arn
log_policy_name = aws_iam_policy.log.name
}
output "log_policy_arn" {
value = local.log_policy_arn
description = "CloudWatch log IAM policy ARN."
}
output "log_policy_name" {
value = local.log_policy_name
description = "CloudWatch log IAM policy name."
}