feat(logs): set custom log group name for API Gateway logs#13283
feat(logs): set custom log group name for API Gateway logs#13283
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughAdds a configurable Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
…nd WebSocket stages
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/serverless/lib/plugins/aws/package/compile/events/api-gateway/lib/hack/update-stage.js (1)
405-423: Avoid deleting user-managed custom log groups.With
logs.logGroupnow supported, disablingaccessLoggingcan delete a user-provided log group that may be shared or managed outside this stack. That’s a data‑loss risk; deletion should be limited to the default log group (or gated by an explicit opt‑in).💡 Suggested safeguard
const logs = provider.logs && provider.logs.restApi - const logGroupName = - (logs && logs.logGroup) || `/aws/api-gateway/${service}-${stage}` + const hasCustomLogGroup = Boolean(logs && logs.logGroup) + const logGroupName = + (logs && logs.logGroup) || `/aws/api-gateway/${service}-${stage}` let accessLogging = logs if (accessLogging) { accessLogging = accessLogging.accessLogging == null ? true : accessLogging.accessLogging } // if there are no logs setup (or the user has disabled them) we need to // ensure that the log group is removed. Otherwise we'll run into duplicate // log group name issues when logs are enabled again if (!accessLogging) { + if (hasCustomLogGroup) return Promise.resolve() return this.provider .request('CloudWatchLogs', 'deleteLogGroup', { logGroupName, })
Adds support for custom CloudWatch log group names for API Gateway access logs via
provider.logs.{restApi|httpApi|websocket}.logGroup, matching the existing pattern for Lambda logs (provider.logs.lambda.logGroup).Usage
Changes
logGroupproperty to schema for restApi, httpApi, and websocket logsSummary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.