aws-cdk-lib.aws_apigateway.LogGroupLogDestination

class LogGroupLogDestination

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.LogGroupLogDestination
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#LogGroupLogDestination
Javasoftware.amazon.awscdk.services.apigateway.LogGroupLogDestination
Pythonaws_cdk.aws_apigateway.LogGroupLogDestination
TypeScript (source)aws-cdk-lib » aws_apigateway » LogGroupLogDestination

Implements IAccessLogDestination

Use CloudWatch Logs as a custom access log destination for API Gateway.

Example

const logGroup = new logs.LogGroup(this, "ApiGatewayAccessLogs");
new apigateway.RestApi(this, 'books', {
  deployOptions: {
    accessLogDestination: new apigateway.LogGroupLogDestination(logGroup),
    accessLogFormat: apigateway.AccessLogFormat.custom(
      `${apigateway.AccessLogField.contextRequestId()} ${apigateway.AccessLogField.contextErrorMessage()} ${apigateway.AccessLogField.contextErrorMessageString()}
      ${apigateway.AccessLogField.contextAuthorizerError()} ${apigateway.AccessLogField.contextAuthorizerIntegrationStatus()}`
    )
  }
});

Initializer

new LogGroupLogDestination(logGroup: ILogGroup)

Parameters

  • logGroup ILogGroup

Methods

NameDescription
bind(_stage)Binds this destination to the CloudWatch Logs.

bind(_stage)

public bind(_stage: IStage): AccessLogDestinationConfig

Parameters

  • _stage IStage

Returns

  • AccessLogDestinationConfig

Binds this destination to the CloudWatch Logs.