-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogs.tf
47 lines (45 loc) · 1.21 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
resource "aws_cloudwatch_log_group" "proxy" {
name = format("%s-requests", var.api_display_name)
}
resource "aws_iam_role_policy" "sigvalid_api_gateway_log_write" {
name = format("%s_policy_log_write", var.api_display_name)
role = aws_iam_role.api_gateway_log_write.id
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
"logs:CreateLogStream",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
],
Resource = aws_cloudwatch_log_group.proxy.arn
},
{
Effect = "Allow",
Action = [
"logs:PutLogEvents",
"logs:GetLogEvents",
"logs:FilterLogEvents"
],
Resource = format("%s:log-stream:*", aws_cloudwatch_log_group.proxy.arn)
}
]
})
}
resource "aws_iam_role" "api_gateway_log_write" {
name = format("api-gateway-log-write-for-%s", var.api_display_name)
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Principal = {
Service = "apigateway.amazonaws.com"
},
Action = "sts:AssumeRole"
}
]
})
}