Skip to content

Commit 5d09295

Browse files
Add API Gateway account settings
1 parent 38b7422 commit 5d09295

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resource "aws_api_gateway_account" "global" {
2+
cloudwatch_role_arn = aws_iam_role.apigateway_logging.arn
3+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
resource "aws_iam_role" "apigateway_logging" {
2+
name = "${local.csi}-logging"
3+
description = "Role used by API Gateway to write logs"
4+
assume_role_policy = data.aws_iam_policy_document.apigateway_assumerole.json
5+
}
6+
7+
data "aws_iam_policy_document" "apigateway_assumerole" {
8+
statement {
9+
sid = "ApigAssumeRole"
10+
effect = "Allow"
11+
12+
actions = [
13+
"sts:AssumeRole",
14+
]
15+
16+
principals {
17+
type = "Service"
18+
19+
identifiers = [
20+
"apigateway.amazonaws.com"
21+
]
22+
}
23+
}
24+
}
25+
26+
resource "aws_iam_role_policy" "apigateway_logging" {
27+
role = aws_iam_role.apigateway_logging.name
28+
name = "${local.csi}-logging"
29+
policy = data.aws_iam_policy_document.apigateway_logging.json
30+
}
31+
32+
data "aws_iam_policy_document" "apigateway_logging" {
33+
statement {
34+
sid = "AllowLogs"
35+
effect = "Allow"
36+
37+
actions = [
38+
"logs:CreateLogGroup",
39+
"logs:CreateLogStream",
40+
"logs:DescribeLogGroups",
41+
"logs:DescribeLogStreams",
42+
"logs:PutLogEvents",
43+
"logs:GetLogEvents",
44+
"logs:FilterLogEvents",
45+
]
46+
47+
resources = ["*"]
48+
}
49+
}
50+

0 commit comments

Comments
 (0)