Skip to content

Commit

Permalink
feat(client-lambda): Adds support for logging configuration in Lambda…
Browse files Browse the repository at this point in the history
… Functions. Customers will have more control how their function logs are captured and to which cloud watch log group they are delivered also.
  • Loading branch information
awstools committed Nov 16, 2023
1 parent 4e07828 commit 3640ab6
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 15 deletions.
12 changes: 12 additions & 0 deletions clients/client-lambda/src/commands/CreateFunctionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ export interface CreateFunctionCommandOutput extends FunctionConfiguration, __Me
* SnapStart: { // SnapStart
* ApplyOn: "PublishedVersions" || "None",
* },
* LoggingConfig: { // LoggingConfig
* LogFormat: "JSON" || "Text",
* ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* LogGroup: "STRING_VALUE",
* },
* };
* const command = new CreateFunctionCommand(input);
* const response = await client.send(command);
Expand Down Expand Up @@ -254,6 +260,12 @@ export interface CreateFunctionCommandOutput extends FunctionConfiguration, __Me
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // };
*
* ```
Expand Down
6 changes: 6 additions & 0 deletions clients/client-lambda/src/commands/GetFunctionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ export interface GetFunctionCommandOutput extends GetFunctionResponse, __Metadat
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // },
* // Code: { // FunctionCodeLocation
* // RepositoryType: "STRING_VALUE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ export interface GetFunctionConfigurationCommandOutput extends FunctionConfigura
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // };
*
* ```
Expand Down
4 changes: 0 additions & 4 deletions clients/client-lambda/src/commands/InvokeAsyncCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ export interface InvokeAsyncCommandOutput extends InvokeAsyncResponse, __Metadat
* <p>For asynchronous function invocation, use <a>Invoke</a>.</p>
* </important>
* <p>Invokes a function asynchronously.</p>
* <note>
* <p>If you do use the InvokeAsync action, note that it doesn't support the use of X-Ray active tracing. Trace ID is not
* propagated to the function, even if X-Ray active tracing is turned on.</p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
6 changes: 6 additions & 0 deletions clients/client-lambda/src/commands/ListFunctionsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ export interface ListFunctionsCommandOutput extends ListFunctionsResponse, __Met
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // },
* // ],
* // };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ export interface ListVersionsByFunctionCommandOutput extends ListVersionsByFunct
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // },
* // ],
* // };
Expand Down
6 changes: 6 additions & 0 deletions clients/client-lambda/src/commands/PublishVersionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ export interface PublishVersionCommandOutput extends FunctionConfiguration, __Me
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // };
*
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ export interface UpdateFunctionCodeCommandOutput extends FunctionConfiguration,
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // };
*
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ export interface UpdateFunctionConfigurationCommandOutput extends FunctionConfig
* SnapStart: { // SnapStart
* ApplyOn: "PublishedVersions" || "None",
* },
* LoggingConfig: { // LoggingConfig
* LogFormat: "JSON" || "Text",
* ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* LogGroup: "STRING_VALUE",
* },
* };
* const command = new UpdateFunctionConfigurationCommand(input);
* const response = await client.send(command);
Expand Down Expand Up @@ -216,6 +222,12 @@ export interface UpdateFunctionConfigurationCommandOutput extends FunctionConfig
* // Message: "STRING_VALUE",
* // },
* // },
* // LoggingConfig: { // LoggingConfig
* // LogFormat: "JSON" || "Text",
* // ApplicationLogLevel: "TRACE" || "DEBUG" || "INFO" || "WARN" || "ERROR" || "FATAL",
* // SystemLogLevel: "DEBUG" || "INFO" || "WARN",
* // LogGroup: "STRING_VALUE",
* // },
* // };
*
* ```
Expand Down
111 changes: 105 additions & 6 deletions clients/client-lambda/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,24 @@ export interface AmazonManagedKafkaEventSourceConfig {
ConsumerGroupId?: string;
}

/**
* @public
* @enum
*/
export const ApplicationLogLevel = {
Debug: "DEBUG",
Error: "ERROR",
Fatal: "FATAL",
Info: "INFO",
Trace: "TRACE",
Warn: "WARN",
} as const;

/**
* @public
*/
export type ApplicationLogLevel = (typeof ApplicationLogLevel)[keyof typeof ApplicationLogLevel];

/**
* @public
* @enum
Expand Down Expand Up @@ -1558,8 +1576,8 @@ export interface Environment {

/**
* @public
* <p>The size of the function's <code>/tmp</code> directory in MB. The default value is 512, but can be any whole
* number between 512 and 10,240 MB. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage">Configuring ephemeral storage (console)</a>.</p>
* <p>The size of the function's <code>/tmp</code> directory in MB. The default value is 512, but it can be any
* whole number between 512 and 10,240 MB.</p>
*/
export interface EphemeralStorage {
/**
Expand Down Expand Up @@ -1614,6 +1632,69 @@ export interface ImageConfig {
WorkingDirectory?: string;
}

/**
* @public
* @enum
*/
export const LogFormat = {
Json: "JSON",
Text: "Text",
} as const;

/**
* @public
*/
export type LogFormat = (typeof LogFormat)[keyof typeof LogFormat];

/**
* @public
* @enum
*/
export const SystemLogLevel = {
Debug: "DEBUG",
Info: "INFO",
Warn: "WARN",
} as const;

/**
* @public
*/
export type SystemLogLevel = (typeof SystemLogLevel)[keyof typeof SystemLogLevel];

/**
* @public
* <p>The function's Amazon CloudWatch Logs configuration settings.</p>
*/
export interface LoggingConfig {
/**
* @public
* <p>The format in which Lambda sends your function's application and system logs to CloudWatch. Select between
* plain text and structured JSON.</p>
*/
LogFormat?: LogFormat;

/**
* @public
* <p>Set this property to filter the application logs for your function that Lambda sends to CloudWatch. Lambda only sends application logs at the
* selected level and lower.</p>
*/
ApplicationLogLevel?: ApplicationLogLevel;

/**
* @public
* <p>Set this property to filter the system logs for your function that Lambda sends to CloudWatch. Lambda only sends system logs at the
* selected level and lower.</p>
*/
SystemLogLevel?: SystemLogLevel;

/**
* @public
* <p>The name of the Amazon CloudWatch log group the function sends logs to. By default, Lambda functions send logs to a default
* log group named <code>/aws/lambda/<function name></code>. To use a different log group, enter an existing log group or enter a new log group name.</p>
*/
LogGroup?: string;
}

/**
* @public
* @enum
Expand Down Expand Up @@ -1928,7 +2009,7 @@ export interface CreateFunctionRequest {
/**
* @public
* <p>The size of the function's <code>/tmp</code> directory in MB. The default value is 512, but can be any whole
* number between 512 and 10,240 MB. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage">Configuring ephemeral storage (console)</a>.</p>
* number between 512 and 10,240 MB.</p>
*/
EphemeralStorage?: EphemeralStorage;

Expand All @@ -1937,6 +2018,12 @@ export interface CreateFunctionRequest {
* <p>The function's <a href="https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html">SnapStart</a> setting.</p>
*/
SnapStart?: SnapStart;

/**
* @public
* <p>The function's Amazon CloudWatch Logs configuration settings.</p>
*/
LoggingConfig?: LoggingConfig;
}

/**
Expand Down Expand Up @@ -2459,8 +2546,8 @@ export interface FunctionConfiguration {

/**
* @public
* <p>The size of the function's <code>/tmp</code> directory in MB. The default value is 512, but can be any whole
* number between 512 and 10,240 MB. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage">Configuring ephemeral storage (console)</a>.</p>
* <p>The size of the functions <code>/tmp</code> directory in MB. The default value is 512, but it can be any
* whole number between 512 and 10,240 MB.</p>
*/
EphemeralStorage?: EphemeralStorage;

Expand All @@ -2476,6 +2563,12 @@ export interface FunctionConfiguration {
* <p>The ARN of the runtime and any errors that occured.</p>
*/
RuntimeVersionConfig?: RuntimeVersionConfig;

/**
* @public
* <p>The function's Amazon CloudWatch Logs configuration settings.</p>
*/
LoggingConfig?: LoggingConfig;
}

/**
Expand Down Expand Up @@ -7002,7 +7095,7 @@ export interface UpdateFunctionConfigurationRequest {
/**
* @public
* <p>The size of the function's <code>/tmp</code> directory in MB. The default value is 512, but can be any whole
* number between 512 and 10,240 MB. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage">Configuring ephemeral storage (console)</a>.</p>
* number between 512 and 10,240 MB.</p>
*/
EphemeralStorage?: EphemeralStorage;

Expand All @@ -7011,6 +7104,12 @@ export interface UpdateFunctionConfigurationRequest {
* <p>The function's <a href="https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html">SnapStart</a> setting.</p>
*/
SnapStart?: SnapStart;

/**
* @public
* <p>The function's Amazon CloudWatch Logs configuration settings.</p>
*/
LoggingConfig?: LoggingConfig;
}

/**
Expand Down
12 changes: 12 additions & 0 deletions clients/client-lambda/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ import {
KMSInvalidStateException,
KMSNotFoundException,
LayerVersionContentInput,
LoggingConfig,
OnFailure,
OnSuccess,
PolicyLengthExceededException,
Expand Down Expand Up @@ -548,6 +549,7 @@ export const se_CreateFunctionCommand = async (
ImageConfig: (_) => _json(_),
KMSKeyArn: [],
Layers: (_) => _json(_),
LoggingConfig: (_) => _json(_),
MemorySize: [],
PackageType: [],
Publish: [],
Expand Down Expand Up @@ -2614,6 +2616,7 @@ export const se_UpdateFunctionConfigurationCommand = async (
ImageConfig: (_) => _json(_),
KMSKeyArn: [],
Layers: (_) => _json(_),
LoggingConfig: (_) => _json(_),
MemorySize: [],
RevisionId: [],
Role: [],
Expand Down Expand Up @@ -3087,6 +3090,7 @@ export const de_CreateFunctionCommand = async (
LastUpdateStatusReason: __expectString,
LastUpdateStatusReasonCode: __expectString,
Layers: _json,
LoggingConfig: _json,
MasterArn: __expectString,
MemorySize: __expectInt32,
PackageType: __expectString,
Expand Down Expand Up @@ -4243,6 +4247,7 @@ export const de_GetFunctionConfigurationCommand = async (
LastUpdateStatusReason: __expectString,
LastUpdateStatusReasonCode: __expectString,
Layers: _json,
LoggingConfig: _json,
MasterArn: __expectString,
MemorySize: __expectInt32,
PackageType: __expectString,
Expand Down Expand Up @@ -5882,6 +5887,7 @@ export const de_PublishVersionCommand = async (
LastUpdateStatusReason: __expectString,
LastUpdateStatusReasonCode: __expectString,
Layers: _json,
LoggingConfig: _json,
MasterArn: __expectString,
MemorySize: __expectInt32,
PackageType: __expectString,
Expand Down Expand Up @@ -6719,6 +6725,7 @@ export const de_UpdateFunctionCodeCommand = async (
LastUpdateStatusReason: __expectString,
LastUpdateStatusReasonCode: __expectString,
Layers: _json,
LoggingConfig: _json,
MasterArn: __expectString,
MemorySize: __expectInt32,
PackageType: __expectString,
Expand Down Expand Up @@ -6827,6 +6834,7 @@ export const de_UpdateFunctionConfigurationCommand = async (
LastUpdateStatusReason: __expectString,
LastUpdateStatusReasonCode: __expectString,
Layers: _json,
LoggingConfig: _json,
MasterArn: __expectString,
MemorySize: __expectInt32,
PackageType: __expectString,
Expand Down Expand Up @@ -7958,6 +7966,8 @@ const se_LayerVersionContentInput = (input: LayerVersionContentInput, context: _
});
};

// se_LoggingConfig omitted.

// se_OnFailure omitted.

// se_OnSuccess omitted.
Expand Down Expand Up @@ -8206,6 +8216,8 @@ const de_FunctionEventInvokeConfigList = (output: any, context: __SerdeContext):

// de_LayerVersionsListItem omitted.

// de_LoggingConfig omitted.

// de_OnFailure omitted.

// de_OnSuccess omitted.
Expand Down
Loading

0 comments on commit 3640ab6

Please sign in to comment.