mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Merge pull request #892 from Hestia-Homes/deploy-fastapi-with-terraform
Deploy fastapi with terraform: api gateway logging
This commit is contained in:
commit
1e7d900a47
1 changed files with 21 additions and 0 deletions
|
|
@ -6,6 +6,14 @@ module "role" {
|
|||
name = "${var.name}-lambda-${var.stage}"
|
||||
}
|
||||
|
||||
############################################
|
||||
# Cloudwatch log group
|
||||
############################################
|
||||
resource "aws_cloudwatch_log_group" "api_logs" {
|
||||
name = "/aws/apigateway/${var.name}-${var.stage}"
|
||||
retention_in_days = 14
|
||||
}
|
||||
|
||||
############################################
|
||||
# Install python packages
|
||||
############################################
|
||||
|
|
@ -68,6 +76,19 @@ resource "aws_apigatewayv2_stage" "this" {
|
|||
api_id = aws_apigatewayv2_api.this.id
|
||||
name = "$default"
|
||||
auto_deploy = true
|
||||
|
||||
access_log_settings {
|
||||
destination_arn = aws_cloudwatch_log_group.api_logs.arn
|
||||
|
||||
format = jsonencode({
|
||||
requestId = "$context.requestId"
|
||||
domainName = "$context.domainName"
|
||||
path = "$context.path"
|
||||
status = "$context.status"
|
||||
sourceIp = "$context.identity.sourceIp"
|
||||
userAgent = "$context.identity.userAgent"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_apigatewayv2_integration" "this" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue