diff --git a/packages/aws-cdk-lib/aws-lambda/lib/function.ts b/packages/aws-cdk-lib/aws-lambda/lib/function.ts index eabc03cab3a38..1f6bcdc9c1274 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/function.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/function.ts @@ -1085,6 +1085,9 @@ export class Function extends FunctionBase { * function and undefined if not. */ private getLoggingConfig(props: FunctionProps): CfnFunction.LoggingConfigProperty | undefined { + if (props.logFormat !== undefined && !Object.values(LogFormat).includes(props.logFormat as LogFormat)) { + throw new TypeError(`'${props.logFormat}' is not a legal LogFormat type.`); + } if ((props.applicationLogLevel || props.systemLogLevel) && props.logFormat !== LogFormat.JSON) { throw new Error(`To use ApplicationLogLevel and/or SystemLogLevel you must set LogFormat to '${LogFormat.JSON}', got '${props.logFormat}'.`); }