Skip to content

Commit

Permalink
Add HttpApi access logs to CloudWatch
Browse files Browse the repository at this point in the history
We already have logs generated for the Lambda function, but it seems
worth having HTTP API logs as well.
  • Loading branch information
mbland committed Apr 10, 2023
1 parent 756d466 commit 716a57e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,27 @@ Resources:
HttpApi:
Type: AWS::Serverless::HttpApi
Properties:
AccessLogSettings:
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-accesslogsettings.html
# https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging.html?icmpid=apigateway_console_help
DestinationArn: !GetAtt ApiAccessLogs.Arn
Format: '"$context.identity.sourceIp - - [$context.requestTime] "$context.httpMethod $context.routeKey $context.protocol" $context.status $context.responseLength $context.requestId"'
DefaultRouteSettings:
# https://stackoverflow.com/a/70423772
# https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html
ThrottlingRateLimit: 10
ThrottlingBurstLimit: 100

ApiAccessLogs:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "${AWS::StackName}-api"

ReceiptRuleSet:
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ses-receiptruleset.html
Type: AWS::SES::ReceiptRuleSet
Properties:
RuleSetName: !Sub "${AWS::StackName}"

ReceiptRuleSetPermission:
Type: AWS::Lambda::Permission
Expand Down

0 comments on commit 716a57e

Please sign in to comment.