Skip to content

Commit c0e7874

Browse files
committed
feat(logging): vpc flow_log
1 parent 224d1b0 commit c0e7874

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

api_gateway.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "aws_apigatewayv2_stage" "main" {
1010
auto_deploy = true
1111

1212
access_log_settings {
13-
destination_arn = aws_cloudwatch_log_group.api_gateway_access_logs.arn
13+
destination_arn = aws_cloudwatch_log_group.api_gateway_access_log.arn
1414
format = "$context.identity.sourceIp - [$context.requestTime] \"$context.routeKey $context.protocol\" $context.status $context.responseLength $context.requestId"
1515
}
1616

cloudwatch.tf

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,34 @@ resource "aws_api_gateway_account" "main" {
44
}
55

66
#tfsec:ignore:aws-cloudwatch-log-group-customer-key
7-
resource "aws_cloudwatch_log_group" "api_gateway_access_logs" {
8-
name = "/aws/apigateway/SOAT-TC_API_Gateway_Access_Logs"
7+
resource "aws_cloudwatch_log_group" "api_gateway_access_log" {
8+
name = "/aws/apigateway/SOAT-TC_API_Gateway_Access_Log"
99
retention_in_days = 30
1010

1111
tags = {
12-
Name : "SOAT-TC API Gateway Default Stage Access Logs"
12+
Name : "SOAT-TC API Gateway Default Stage Access Log Cloudwatch Log Group"
13+
}
14+
}
15+
16+
resource "aws_flow_log" "vpc" {
17+
iam_role_arn = data.aws_iam_role.lab_role.arn
18+
log_destination = aws_cloudwatch_log_group.vpc_flow_log.arn
19+
traffic_type = "ALL"
20+
vpc_id = aws_vpc.main.id
21+
22+
max_aggregation_interval = 60
23+
24+
tags = {
25+
Name : "SOAT-TC VPC Flow Log"
26+
}
27+
}
28+
29+
#tfsec:ignore:aws-cloudwatch-log-group-customer-key
30+
resource "aws_cloudwatch_log_group" "vpc_flow_log" {
31+
name = "/aws/apigateway/SOAT-TC_VPC_Flow_Logs"
32+
retention_in_days = 30
33+
34+
tags = {
35+
Name : "SOAT-TC VPC Flow Log Cloudwatch Log Group"
1336
}
1437
}

0 commit comments

Comments
 (0)