Skip to content

Commit 8256db3

Browse files
brendanbabbclaude
andcommitted
Tag CloudWatch log groups with Project=mcp-server
Add `Project = mcp-server` tags so the mcp-observability project can discover these log groups via the Resource Groups Tagging API. - Lambda log group (/aws/lambda/...): add tags block. - API Gateway access log group (/aws/apigateway/...-access): this group did not exist, so create it and wire access_log_settings on the prod stage to emit access logs to it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5a7ede2 commit 8256db3

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

terraform/aws/api_gateway.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,37 @@ resource "aws_api_gateway_deployment" "mcp_deployment" {
144144
]
145145
}
146146

147+
# CloudWatch Log Group for API Gateway access logs
148+
resource "aws_cloudwatch_log_group" "apigw_access_logs" {
149+
name = "/aws/apigateway/${local.lambda_name}-access"
150+
retention_in_days = 14
151+
152+
tags = {
153+
Project = "mcp-server"
154+
}
155+
}
156+
147157
# API Gateway Stage
148158
resource "aws_api_gateway_stage" "prod" {
149159
deployment_id = aws_api_gateway_deployment.mcp_deployment.id
150160
rest_api_id = aws_api_gateway_rest_api.mcp_api.id
151161
stage_name = var.stage_name
152162

153163
xray_tracing_enabled = true
164+
165+
access_log_settings {
166+
destination_arn = aws_cloudwatch_log_group.apigw_access_logs.arn
167+
format = jsonencode({
168+
requestId = "$context.requestId"
169+
ip = "$context.identity.sourceIp"
170+
requestTime = "$context.requestTime"
171+
httpMethod = "$context.httpMethod"
172+
resourcePath = "$context.resourcePath"
173+
status = "$context.status"
174+
protocol = "$context.protocol"
175+
responseLength = "$context.responseLength"
176+
})
177+
}
154178
}
155179

156180
# Method Settings: Throttling for all methods in stage (AWS format: */* not /*/*)

terraform/aws/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,8 @@ resource "aws_lambda_function_url" "mcp_server_url" {
105105
resource "aws_cloudwatch_log_group" "lambda_logs" {
106106
name = "/aws/lambda/${local.lambda_name}"
107107
retention_in_days = 14
108+
109+
tags = {
110+
Project = "mcp-server"
111+
}
108112
}

0 commit comments

Comments
 (0)