Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(lambda): validate logLevel with logFormat for advanced logging (#…
…28045) This PR adds to validate whether `applicationLogLevel` and `systemLogLevel` have a JSON `logFormat` for advanced logging. The doc states the following: > To use log-level filtering, your function must be configured to use the JSON log format. The default log format for all Lambda managed runtimes is currently plain text. To learn how to configure your function's log format to JSON, see [Setting your function's log format](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-set-format). https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced If you specify `systemLogLevel` or `applicationLogLevel` without `LogFormat.JSON` like the following code, an error occurred in a CFn event: ``` Resource handler returned message: "LogLevel is not supported when LogFormat is set to "Text". Remove LogLevel from your request or change the LogFormat to "Json" and try again. ``` ```ts new Function(stack, 'LambdaWithLogLevel', { code: new InlineCode('foo'), handler: 'index.handler', runtime: Runtime.NODEJS_18_X, logFormat: LogFormat.TEXT, systemLogLevel: SystemLogLevel.INFO, applicationLogLevel: ApplicationLogLevel.INFO, }); ``` This validation allows the error to be caught at the synth phase. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information