AccessLogField Class
$context variables that can be used to customize access log pattern.
Example
apigateway.AccessLogFormat.custom(JSON.stringify({
requestId: apigateway.AccessLogField.contextRequestId(),
sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(),
method: apigateway.AccessLogField.contextHttpMethod(),
userContext: {
sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'),
email: apigateway.AccessLogField.contextAuthorizerClaims('email')
}
}))
apigateway.AccessLogFormat.custom(JSON.stringify({
"request_id": apigateway.AccessLogField.context_request_id(),
"source_ip": apigateway.AccessLogField.context_identity_source_ip(),
"method": apigateway.AccessLogField.context_http_method(),
"user_context": {
"sub": apigateway.AccessLogField.context_authorizer_claims("sub"),
"email": apigateway.AccessLogField.context_authorizer_claims("email")
}
}))
AccessLogFormat.custom(JSON.stringify(Map.of(
"requestId", AccessLogField.contextRequestId(),
"sourceIp", AccessLogField.contextIdentitySourceIp(),
"method", AccessLogField.contextHttpMethod(),
"userContext", Map.of(
"sub", AccessLogField.contextAuthorizerClaims("sub"),
"email", AccessLogField.contextAuthorizerClaims("email")))));
// Install: dotnet add package Amazon.CDK.Lib
AccessLogFormat.Custom(JSON.Stringify(new Dictionary<string, object> {
{ "requestId", AccessLogField.ContextRequestId() },
{ "sourceIp", AccessLogField.ContextIdentitySourceIp() },
{ "method", AccessLogField.ContextHttpMethod() },
{ "userContext", new Struct {
Sub = AccessLogField.ContextAuthorizerClaims("sub"),
Email = AccessLogField.ContextAuthorizerClaims("email")
} }
}));
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
apigateway.AccessLogFormat_Custom(jSON.stringify(map[string]interface{}{
"requestId": apigateway.AccessLogField_contextRequestId(),
"sourceIp": apigateway.AccessLogField_contextIdentitySourceIp(),
"method": apigateway.AccessLogField_contextHttpMethod(),
"userContext": map[string]*string{
"sub": apigateway.AccessLogField_contextAuthorizerClaims(jsii.String("sub")),
"email": apigateway.AccessLogField_contextAuthorizerClaims(jsii.String("email")),
},
}))
Initializer
new AccessLogField()
AccessLogField()
new AccessLogField()
new AccessLogField()
NewAccessLogField()
Methods
contextAccountId(): string@staticmethod def context_account_id() -> strpublic static String contextAccountId()public static string ContextAccountId()func ContextAccountId() *stringstaticdeprecated#contextApiId(): string@staticmethod def context_api_id() -> strpublic static String contextApiId()public static string ContextApiId()func ContextApiId() *stringstatic#contextAuthenticateError(): string@staticmethod def context_authenticate_error() -> strpublic static String contextAuthenticateError()public static string ContextAuthenticateError()func ContextAuthenticateError() *stringstatic#contextAuthenticateLatency(): string@staticmethod def context_authenticate_latency() -> strpublic static String contextAuthenticateLatency()public static string ContextAuthenticateLatency()func ContextAuthenticateLatency() *stringstatic#contextAuthenticateStatus(): string@staticmethod def context_authenticate_status() -> strpublic static String contextAuthenticateStatus()public static string ContextAuthenticateStatus()func ContextAuthenticateStatus() *stringstatic#contextAuthorizeError(): string@staticmethod def context_authorize_error() -> strpublic static String contextAuthorizeError()public static string ContextAuthorizeError()func ContextAuthorizeError() *stringstatic#contextAuthorizeLatency(): string@staticmethod def context_authorize_latency() -> strpublic static String contextAuthorizeLatency()public static string ContextAuthorizeLatency()func ContextAuthorizeLatency() *stringstatic#contextAuthorizer(property: string): string@staticmethod def context_authorizer(property: str) -> strpublic static String contextAuthorizer(String property)public static string ContextAuthorizer(string property)func ContextAuthorizer(Property *string) *stringstatic#1 parameter
Parameters
propertypropertypropertypropertyProperty— key of the context map.
contextAuthorizerClaims(property: string): string@staticmethod def context_authorizer_claims(property: str) -> strpublic static String contextAuthorizerClaims(String property)public static string ContextAuthorizerClaims(string property)func ContextAuthorizerClaims(Property *string) *stringstatic#1 parameter
Parameters
propertypropertypropertypropertyProperty— A property key of the claims.
contextAuthorizerError(): string@staticmethod def context_authorizer_error() -> strpublic static String contextAuthorizerError()public static string ContextAuthorizerError()func ContextAuthorizerError() *stringstatic#contextAuthorizerIntegrationLatency(): string@staticmethod def context_authorizer_integration_latency() -> strpublic static String contextAuthorizerIntegrationLatency()public static string ContextAuthorizerIntegrationLatency()func ContextAuthorizerIntegrationLatency() *stringstatic#contextAuthorizerIntegrationStatus(): string@staticmethod def context_authorizer_integration_status() -> strpublic static String contextAuthorizerIntegrationStatus()public static string ContextAuthorizerIntegrationStatus()func ContextAuthorizerIntegrationStatus() *stringstatic#contextAuthorizerLatency(): string@staticmethod def context_authorizer_latency() -> strpublic static String contextAuthorizerLatency()public static string ContextAuthorizerLatency()func ContextAuthorizerLatency() *stringstatic#contextAuthorizerPrincipalId(): string@staticmethod def context_authorizer_principal_id() -> strpublic static String contextAuthorizerPrincipalId()public static string ContextAuthorizerPrincipalId()func ContextAuthorizerPrincipalId() *stringstatic#contextAuthorizerRequestId(): string@staticmethod def context_authorizer_request_id() -> strpublic static String contextAuthorizerRequestId()public static string ContextAuthorizerRequestId()func ContextAuthorizerRequestId() *stringstatic#contextAuthorizerStatus(): string@staticmethod def context_authorizer_status() -> strpublic static String contextAuthorizerStatus()public static string ContextAuthorizerStatus()func ContextAuthorizerStatus() *stringstatic#contextAuthorizeStatus(): string@staticmethod def context_authorize_status() -> strpublic static String contextAuthorizeStatus()public static string ContextAuthorizeStatus()func ContextAuthorizeStatus() *stringstatic#contextAwsEndpointRequestId(): string@staticmethod def context_aws_endpoint_request_id() -> strpublic static String contextAwsEndpointRequestId()public static string ContextAwsEndpointRequestId()func ContextAwsEndpointRequestId() *stringstatic#contextCallerAccountId(): string@staticmethod def context_caller_account_id() -> strpublic static String contextCallerAccountId()public static string ContextCallerAccountId()func ContextCallerAccountId() *stringstatic#contextConnectionId(): string@staticmethod def context_connection_id() -> strpublic static String contextConnectionId()public static string ContextConnectionId()func ContextConnectionId() *stringstatic#contextCustomDomainBasePathMatched(): string@staticmethod def context_custom_domain_base_path_matched() -> strpublic static String contextCustomDomainBasePathMatched()public static string ContextCustomDomainBasePathMatched()func ContextCustomDomainBasePathMatched() *stringstatic#Applicable when a client uses a custom domain name to access an API. For example if a client sends a request to https://api.example.com/v1/orders/1234, and the request matches the API mapping with the path v1/orders, the value is v1/orders.
contextDomainName(): string@staticmethod def context_domain_name() -> strpublic static String contextDomainName()public static string ContextDomainName()func ContextDomainName() *stringstatic#This should be the same as the incoming Host header.
contextDomainPrefix(): string@staticmethod def context_domain_prefix() -> strpublic static String contextDomainPrefix()public static string ContextDomainPrefix()func ContextDomainPrefix() *stringstatic#contextErrorMessage(): string@staticmethod def context_error_message() -> strpublic static String contextErrorMessage()public static string ContextErrorMessage()func ContextErrorMessage() *stringstatic#contextErrorMessageString(): string@staticmethod def context_error_message_string() -> strpublic static String contextErrorMessageString()public static string ContextErrorMessageString()func ContextErrorMessageString() *stringstatic#contextErrorResponseType(): string@staticmethod def context_error_response_type() -> strpublic static String contextErrorResponseType()public static string ContextErrorResponseType()func ContextErrorResponseType() *stringstatic#This variable can only be used for simple variable substitution in a GatewayResponse body-mapping template, which is not processed by the Velocity Template Language engine, and in access logging.
contextErrorValidationErrorString(): string@staticmethod def context_error_validation_error_string() -> strpublic static String contextErrorValidationErrorString()public static string ContextErrorValidationErrorString()func ContextErrorValidationErrorString() *stringstatic#contextEventType(): string@staticmethod def context_event_type() -> strpublic static String contextEventType()public static string ContextEventType()func ContextEventType() *stringstatic#contextExtendedRequestId(): string@staticmethod def context_extended_request_id() -> strpublic static String contextExtendedRequestId()public static string ContextExtendedRequestId()func ContextExtendedRequestId() *stringstatic#contextHttpMethod(): string@staticmethod def context_http_method() -> strpublic static String contextHttpMethod()public static string ContextHttpMethod()func ContextHttpMethod() *stringstatic#Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
contextIdentityAccountId(): string@staticmethod def context_identity_account_id() -> strpublic static String contextIdentityAccountId()public static string ContextIdentityAccountId()func ContextIdentityAccountId() *stringstatic#contextIdentityApiKey(): string@staticmethod def context_identity_api_key() -> strpublic static String contextIdentityApiKey()public static string ContextIdentityApiKey()func ContextIdentityApiKey() *stringstatic#For methods that don't require an API key, this variable is
contextIdentityApiKeyId(): string@staticmethod def context_identity_api_key_id() -> strpublic static String contextIdentityApiKeyId()public static string ContextIdentityApiKeyId()func ContextIdentityApiKeyId() *stringstatic#contextIdentityCaller(): string@staticmethod def context_identity_caller() -> strpublic static String contextIdentityCaller()public static string ContextIdentityCaller()func ContextIdentityCaller() *stringstatic#contextIdentityClientCertIssunerDN(): string@staticmethod def context_identity_client_cert_issuner_dn() -> strpublic static String contextIdentityClientCertIssunerDN()public static string ContextIdentityClientCertIssunerDN()func ContextIdentityClientCertIssunerDN() *stringstatic#Present when a client accesses an API by using a custom domain name that has mutual TLS enabled. Present only in access logs if mutual TLS authentication fails.
contextIdentityClientCertPem(): string@staticmethod def context_identity_client_cert_pem() -> strpublic static String contextIdentityClientCertPem()public static string ContextIdentityClientCertPem()func ContextIdentityClientCertPem() *stringstatic#Present when a client accesses an API by using a custom domain name that has mutual TLS enabled. Present only in access logs if mutual TLS authentication fails.
contextIdentityClientCertSerialNumber(): string@staticmethod def context_identity_client_cert_serial_number() -> strpublic static String contextIdentityClientCertSerialNumber()public static string ContextIdentityClientCertSerialNumber()func ContextIdentityClientCertSerialNumber() *stringstatic#Present when a client accesses an API by using a custom domain name that has mutual TLS enabled. Present only in access logs if mutual TLS authentication fails.
contextIdentityClientCertSubjectDN(): string@staticmethod def context_identity_client_cert_subject_dn() -> strpublic static String contextIdentityClientCertSubjectDN()public static string ContextIdentityClientCertSubjectDN()func ContextIdentityClientCertSubjectDN() *stringstatic#Present when a client accesses an API by using a custom domain name that has mutual TLS enabled. Present only in access logs if mutual TLS authentication fails.
contextIdentityClientCertValidityNotAfter(): string@staticmethod def context_identity_client_cert_validity_not_after() -> strpublic static String contextIdentityClientCertValidityNotAfter()public static string ContextIdentityClientCertValidityNotAfter()func ContextIdentityClientCertValidityNotAfter() *stringstatic#Present when a client accesses an API by using a custom domain name that has mutual TLS enabled. Present only in access logs if mutual TLS authentication fails.
contextIdentityClientCertValidityNotBefore(): string@staticmethod def context_identity_client_cert_validity_not_before() -> strpublic static String contextIdentityClientCertValidityNotBefore()public static string ContextIdentityClientCertValidityNotBefore()func ContextIdentityClientCertValidityNotBefore() *stringstatic#Present when a client accesses an API by using a custom domain name that has mutual TLS enabled. Present only in access logs if mutual TLS authentication fails.
contextIdentityCognitoAuthenticationProvider(): string@staticmethod def context_identity_cognito_authentication_provider() -> strpublic static String contextIdentityCognitoAuthenticationProvider()public static string ContextIdentityCognitoAuthenticationProvider()func ContextIdentityCognitoAuthenticationProvider() *stringstatic#Available only if the request was signed with Amazon Cognito credentials.
contextIdentityCognitoAuthenticationType(): string@staticmethod def context_identity_cognito_authentication_type() -> strpublic static String contextIdentityCognitoAuthenticationType()public static string ContextIdentityCognitoAuthenticationType()func ContextIdentityCognitoAuthenticationType() *stringstatic#Available only if the request was signed with Amazon Cognito credentials.
contextIdentityCognitoIdentityId(): string@staticmethod def context_identity_cognito_identity_id() -> strpublic static String contextIdentityCognitoIdentityId()public static string ContextIdentityCognitoIdentityId()func ContextIdentityCognitoIdentityId() *stringstatic#Available only if the request was signed with Amazon Cognito credentials.
contextIdentityCognitoIdentityPoolId(): string@staticmethod def context_identity_cognito_identity_pool_id() -> strpublic static String contextIdentityCognitoIdentityPoolId()public static string ContextIdentityCognitoIdentityPoolId()func ContextIdentityCognitoIdentityPoolId() *stringstatic#Available only if the request was signed with Amazon Cognito credentials.
contextIdentityPrincipalOrgId(): string@staticmethod def context_identity_principal_org_id() -> strpublic static String contextIdentityPrincipalOrgId()public static string ContextIdentityPrincipalOrgId()func ContextIdentityPrincipalOrgId() *stringstatic#contextIdentitySourceIp(): string@staticmethod def context_identity_source_ip() -> strpublic static String contextIdentitySourceIp()public static string ContextIdentitySourceIp()func ContextIdentitySourceIp() *stringstatic#Warning: You should not trust this value if there is any chance that the X-Forwarded-For header could be forged.
contextIdentityUser(): string@staticmethod def context_identity_user() -> strpublic static String contextIdentityUser()public static string ContextIdentityUser()func ContextIdentityUser() *stringstatic#Used in Lambda authorizers.
contextIdentityUserAgent(): string@staticmethod def context_identity_user_agent() -> strpublic static String contextIdentityUserAgent()public static string ContextIdentityUserAgent()func ContextIdentityUserAgent() *stringstatic#contextIdentityUserArn(): string@staticmethod def context_identity_user_arn() -> strpublic static String contextIdentityUserArn()public static string ContextIdentityUserArn()func ContextIdentityUserArn() *stringstatic#contextIntegrationErrorMessage(): string@staticmethod def context_integration_error_message() -> strpublic static String contextIntegrationErrorMessage()public static string ContextIntegrationErrorMessage()func ContextIntegrationErrorMessage() *stringstatic#contextIntegrationLatency(): string@staticmethod def context_integration_latency() -> strpublic static String contextIntegrationLatency()public static string ContextIntegrationLatency()func ContextIntegrationLatency() *stringstatic#contextIntegrationStatus(): string@staticmethod def context_integration_status() -> strpublic static String contextIntegrationStatus()public static string ContextIntegrationStatus()func ContextIntegrationStatus() *stringstatic#contextOwnerAccountId(): string@staticmethod def context_owner_account_id() -> strpublic static String contextOwnerAccountId()public static string ContextOwnerAccountId()func ContextOwnerAccountId() *stringstatic#contextPath(): string@staticmethod def context_path() -> strpublic static String contextPath()public static string ContextPath()func ContextPath() *stringstatic#For example, for a non-proxy request URL of https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child, this value is /{stage}/root/child.
contextProtocol(): string@staticmethod def context_protocol() -> strpublic static String contextProtocol()public static string ContextProtocol()func ContextProtocol() *stringstatic#contextRequestId(): string@staticmethod def context_request_id() -> strpublic static String contextRequestId()public static string ContextRequestId()func ContextRequestId() *stringstatic#contextRequestOverrideHeader(headerName: string): string@staticmethod def context_request_override_header(header_name: str) -> strpublic static String contextRequestOverrideHeader(String headerName)public static string ContextRequestOverrideHeader(string headerName)func ContextRequestOverrideHeader(HeaderName *string) *stringstatic#If this parameter is defined, it contains the headers to be used instead of the HTTP Headers that are defined in the Integration Request pane.
contextRequestOverridePath(pathName: string): string@staticmethod def context_request_override_path(path_name: str) -> strpublic static String contextRequestOverridePath(String pathName)public static string ContextRequestOverridePath(string pathName)func ContextRequestOverridePath(PathName *string) *stringstatic#If this parameter is defined, it contains the request path to be used instead of the URL Path Parameters that are defined in the Integration Request pane.
contextRequestOverrideQuerystring(querystringName: string): string@staticmethod def context_request_override_querystring(querystring_name: str) -> strpublic static String contextRequestOverrideQuerystring(String querystringName)public static string ContextRequestOverrideQuerystring(string querystringName)func ContextRequestOverrideQuerystring(QuerystringName *string) *stringstatic#If this parameter is defined, it contains the request query strings to be used instead of the URL Query String Parameters that are defined in the Integration Request pane.
contextRequestTime(): string@staticmethod def context_request_time() -> strpublic static String contextRequestTime()public static string ContextRequestTime()func ContextRequestTime() *stringstatic#contextRequestTimeEpoch(): string@staticmethod def context_request_time_epoch() -> strpublic static String contextRequestTimeEpoch()public static string ContextRequestTimeEpoch()func ContextRequestTimeEpoch() *stringstatic#contextResourceId(): string@staticmethod def context_resource_id() -> strpublic static String contextResourceId()public static string ContextResourceId()func ContextResourceId() *stringstatic#contextResourcePath(): string@staticmethod def context_resource_path() -> strpublic static String contextResourcePath()public static string ContextResourcePath()func ContextResourcePath() *stringstatic#For example, for the non-proxy request URI of https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child, The $context.resourcePath value is /root/child.
contextResponseLatency(): string@staticmethod def context_response_latency() -> strpublic static String contextResponseLatency()public static string ContextResponseLatency()func ContextResponseLatency() *stringstatic#contextResponseLength(): string@staticmethod def context_response_length() -> strpublic static String contextResponseLength()public static string ContextResponseLength()func ContextResponseLength() *stringstatic#contextResponseOverrideHeader(headerName: string): string@staticmethod def context_response_override_header(header_name: str) -> strpublic static String contextResponseOverrideHeader(String headerName)public static string ContextResponseOverrideHeader(string headerName)func ContextResponseOverrideHeader(HeaderName *string) *stringstatic#If this parameter is defined, it contains the header to be returned instead of the Response header that is defined as the Default mapping in the Integration Response pane.
contextResponseOverrideStatus(): string@staticmethod def context_response_override_status() -> strpublic static String contextResponseOverrideStatus()public static string ContextResponseOverrideStatus()func ContextResponseOverrideStatus() *stringstatic#If this parameter is defined, it contains the status code to be returned instead of the Method response status that is defined as the Default mapping in the Integration Response pane.
contextRouteKey(): string@staticmethod def context_route_key() -> strpublic static String contextRouteKey()public static string ContextRouteKey()func ContextRouteKey() *stringstatic#contextStage(): string@staticmethod def context_stage() -> strpublic static String contextStage()public static string ContextStage()func ContextStage() *stringstatic#contextStatus(): string@staticmethod def context_status() -> strpublic static String contextStatus()public static string ContextStatus()func ContextStatus() *stringstatic#contextWafError(): string@staticmethod def context_waf_error() -> strpublic static String contextWafError()public static string ContextWafError()func ContextWafError() *stringstatic#contextWafLatency(): string@staticmethod def context_waf_latency() -> strpublic static String contextWafLatency()public static string ContextWafLatency()func ContextWafLatency() *stringstatic#contextWafResponseCode(): string@staticmethod def context_waf_response_code() -> strpublic static String contextWafResponseCode()public static string ContextWafResponseCode()func ContextWafResponseCode() *stringstatic#Will not be set if the stage is not associated with a web ACL.
contextWafStatus(): string@staticmethod def context_waf_status() -> strpublic static String contextWafStatus()public static string ContextWafStatus()func ContextWafStatus() *stringstatic#contextWebaclArn(): string@staticmethod def context_webacl_arn() -> strpublic static String contextWebaclArn()public static string ContextWebaclArn()func ContextWebaclArn() *stringstatic#Will not be set if the stage is not associated with a web ACL.
contextXrayTraceId(): string@staticmethod def context_xray_trace_id() -> strpublic static String contextXrayTraceId()public static string ContextXrayTraceId()func ContextXrayTraceId() *stringstatic#