Class AccessLogField

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.apigateway.AccessLogField
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.95.0 (build f1ff514)", date="2024-03-26T18:09:18.747Z") @Stability(Stable) public class AccessLogField extends software.amazon.jsii.JsiiObject
$context variables that can be used to customize access log pattern.

Example:

 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")))));
 
  • Constructor Details

    • AccessLogField

      protected AccessLogField(software.amazon.jsii.JsiiObjectRef objRef)
    • AccessLogField

      protected AccessLogField(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • AccessLogField

      @Stability(Stable) public AccessLogField()
  • Method Details

    • contextAccountId

      @Stability(Deprecated) @Deprecated @NotNull public static String contextAccountId()
      Deprecated.
      Use contextCallerAccountId or contextOwnerAccountId instead
      (deprecated) The API callers AWS account ID.

    • contextApiId

      @Stability(Stable) @NotNull public static String contextApiId()
      The identifier API Gateway assigns to your API.
    • contextAuthenticateError

      @Stability(Stable) @NotNull public static String contextAuthenticateError()
      The error message returned from an authentication attempt.
    • contextAuthenticateLatency

      @Stability(Stable) @NotNull public static String contextAuthenticateLatency()
      The authentication latency in ms.
    • contextAuthenticateStatus

      @Stability(Stable) @NotNull public static String contextAuthenticateStatus()
      The status code returned from an authentication attempt.
    • contextAuthorizeError

      @Stability(Stable) @NotNull public static String contextAuthorizeError()
      The authorization error message.
    • contextAuthorizeLatency

      @Stability(Stable) @NotNull public static String contextAuthorizeLatency()
      The authorization latency in ms.
    • contextAuthorizer

      @Stability(Stable) @NotNull public static String contextAuthorizer(@NotNull String property)
      The stringified value of the specified key-value pair of the context map returned from an API Gateway Lambda authorizer function.

      Parameters:
      property - key of the context map. This parameter is required.
      See Also:
    • contextAuthorizerClaims

      @Stability(Stable) @NotNull public static String contextAuthorizerClaims(@NotNull String property)
      A property of the claims returned from the Amazon Cognito user pool after the method caller is successfully authenticated.

      Parameters:
      property - A property key of the claims. This parameter is required.
      See Also:
    • contextAuthorizerError

      @Stability(Stable) @NotNull public static String contextAuthorizerError()
      The error message returned from an authorizer.
    • contextAuthorizerIntegrationLatency

      @Stability(Stable) @NotNull public static String contextAuthorizerIntegrationLatency()
      The authorizer latency in ms.
    • contextAuthorizerIntegrationStatus

      @Stability(Stable) @NotNull public static String contextAuthorizerIntegrationStatus()
      The status code returned from a Lambda authorizer.
    • contextAuthorizerLatency

      @Stability(Stable) @NotNull public static String contextAuthorizerLatency()
      The authorizer latency in ms.
    • contextAuthorizerPrincipalId

      @Stability(Stable) @NotNull public static String contextAuthorizerPrincipalId()
      The principal user identification associated with the token sent by the client and returned from an API Gateway Lambda authorizer (formerly known as a custom authorizer).

      See Also:
    • contextAuthorizerRequestId

      @Stability(Stable) @NotNull public static String contextAuthorizerRequestId()
      The AWS endpoint's request ID.
    • contextAuthorizerStatus

      @Stability(Stable) @NotNull public static String contextAuthorizerStatus()
      The status code returned from an authorizer.
    • contextAuthorizeStatus

      @Stability(Stable) @NotNull public static String contextAuthorizeStatus()
      The status code returned from an authorization attempt.
    • contextAwsEndpointRequestId

      @Stability(Stable) @NotNull public static String contextAwsEndpointRequestId()
      The AWS endpoint's request ID.
    • contextCallerAccountId

      @Stability(Stable) @NotNull public static String contextCallerAccountId()
      The API callers AWS account ID.
    • contextCustomDomainBasePathMatched

      @Stability(Stable) @NotNull public static String contextCustomDomainBasePathMatched()
      The path for an API mapping that an incoming request matched.

      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.

      See Also:
    • contextDomainName

      @Stability(Stable) @NotNull public static String contextDomainName()
      The full domain name used to invoke the API.

      This should be the same as the incoming Host header.

    • contextDomainPrefix

      @Stability(Stable) @NotNull public static String contextDomainPrefix()
      The first label of the $context.domainName. This is often used as a caller/customer identifier.
    • contextErrorMessage

      @Stability(Stable) @NotNull public static String contextErrorMessage()
      A string containing an API Gateway error message.
    • contextErrorMessageString

      @Stability(Stable) @NotNull public static String contextErrorMessageString()
      The quoted value of $context.error.message, namely "$context.error.message".
    • contextErrorResponseType

      @Stability(Stable) @NotNull public static String contextErrorResponseType()
      A type of GatewayResponse.

      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.

      See Also:
    • contextErrorValidationErrorString

      @Stability(Stable) @NotNull public static String contextErrorValidationErrorString()
      A string containing a detailed validation error message.
    • contextExtendedRequestId

      @Stability(Stable) @NotNull public static String contextExtendedRequestId()
      The extended ID that API Gateway assigns to the API request, which contains more useful information for debugging/troubleshooting.
    • contextHttpMethod

      @Stability(Stable) @NotNull public static String contextHttpMethod()
      The HTTP method used.

      Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.

    • contextIdentityAccountId

      @Stability(Stable) @NotNull public static String contextIdentityAccountId()
      The AWS account ID associated with the request.
    • contextIdentityApiKey

      @Stability(Stable) @NotNull public static String contextIdentityApiKey()
      For API methods that require an API key, this variable is the API key associated with the method request.

      For methods that don't require an API key, this variable is

      See Also:
    • contextIdentityApiKeyId

      @Stability(Stable) @NotNull public static String contextIdentityApiKeyId()
      The API key ID associated with an API request that requires an API key.
    • contextIdentityCaller

      @Stability(Stable) @NotNull public static String contextIdentityCaller()
      The principal identifier of the caller making the request.
    • contextIdentityClientCertIssunerDN

      @Stability(Stable) @NotNull public static String contextIdentityClientCertIssunerDN()
      The distinguished name of the issuer of the certificate that a client presents.

      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

      @Stability(Stable) @NotNull public static String contextIdentityClientCertPem()
      The PEM-encoded client certificate that the client presented during mutual TLS authentication.

      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

      @Stability(Stable) @NotNull public static String contextIdentityClientCertSerialNumber()
      The serial number of the certificate.

      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

      @Stability(Stable) @NotNull public static String contextIdentityClientCertSubjectDN()
      The distinguished name of the subject of the certificate that a client presents.

      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

      @Stability(Stable) @NotNull public static String contextIdentityClientCertValidityNotAfter()
      The date after which the certificate is invalid.

      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

      @Stability(Stable) @NotNull public static String contextIdentityClientCertValidityNotBefore()
      The date before which the certificate is invalid.

      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

      @Stability(Stable) @NotNull public static String contextIdentityCognitoAuthenticationProvider()
      The Amazon Cognito authentication provider used by the caller making the request.

      Available only if the request was signed with Amazon Cognito credentials.

      See Also:
    • contextIdentityCognitoAuthenticationType

      @Stability(Stable) @NotNull public static String contextIdentityCognitoAuthenticationType()
      The Amazon Cognito authentication type of the caller making the request.

      Available only if the request was signed with Amazon Cognito credentials.

    • contextIdentityCognitoIdentityId

      @Stability(Stable) @NotNull public static String contextIdentityCognitoIdentityId()
      The Amazon Cognito identity ID of the caller making the request.

      Available only if the request was signed with Amazon Cognito credentials.

    • contextIdentityCognitoIdentityPoolId

      @Stability(Stable) @NotNull public static String contextIdentityCognitoIdentityPoolId()
      The Amazon Cognito identity pool ID of the caller making the request.

      Available only if the request was signed with Amazon Cognito credentials.

    • contextIdentityPrincipalOrgId

      @Stability(Stable) @NotNull public static String contextIdentityPrincipalOrgId()
      The AWS organization ID.
    • contextIdentitySourceIp

      @Stability(Stable) @NotNull public static String contextIdentitySourceIp()
      The source IP address of the TCP connection making the request to API Gateway.

      Warning: You should not trust this value if there is any chance that the X-Forwarded-For header could be forged.

    • contextIdentityUser

      @Stability(Stable) @NotNull public static String contextIdentityUser()
      The principal identifier of the user making the request.

      Used in Lambda authorizers.

      See Also:
    • contextIdentityUserAgent

      @Stability(Stable) @NotNull public static String contextIdentityUserAgent()
      The User-Agent header of the API caller.
    • contextIdentityUserArn

      @Stability(Stable) @NotNull public static String contextIdentityUserArn()
      The Amazon Resource Name (ARN) of the effective user identified after authentication.

      See Also:
    • contextIntegrationErrorMessage

      @Stability(Stable) @NotNull public static String contextIntegrationErrorMessage()
      A string that contains an integration error message.
    • contextIntegrationLatency

      @Stability(Stable) @NotNull public static String contextIntegrationLatency()
      The integration latency in ms.
    • contextIntegrationStatus

      @Stability(Stable) @NotNull public static String contextIntegrationStatus()
      For Lambda proxy integration, this parameter represents the status code returned from AWS Lambda, not from the backend Lambda function.
    • contextOwnerAccountId

      @Stability(Stable) @NotNull public static String contextOwnerAccountId()
      The API owner's AWS account ID.
    • contextPath

      @Stability(Stable) @NotNull public static String contextPath()
      The request path.

      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

      @Stability(Stable) @NotNull public static String contextProtocol()
      The request protocol, for example, HTTP/1.1.
    • contextRequestId

      @Stability(Stable) @NotNull public static String contextRequestId()
      The ID that API Gateway assigns to the API request.
    • contextRequestOverrideHeader

      @Stability(Stable) @NotNull public static String contextRequestOverrideHeader(@NotNull String headerName)
      The request header override.

      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.

      Parameters:
      headerName - This parameter is required.
      See Also:
    • contextRequestOverridePath

      @Stability(Stable) @NotNull public static String contextRequestOverridePath(@NotNull String pathName)
      The request path override.

      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.

      Parameters:
      pathName - This parameter is required.
      See Also:
    • contextRequestOverrideQuerystring

      @Stability(Stable) @NotNull public static String contextRequestOverrideQuerystring(@NotNull String querystringName)
      The request query string override.

      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.

      Parameters:
      querystringName - This parameter is required.
    • contextRequestTime

      @Stability(Stable) @NotNull public static String contextRequestTime()
      The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
    • contextRequestTimeEpoch

      @Stability(Stable) @NotNull public static String contextRequestTimeEpoch()
      The Epoch-formatted request time.
    • contextResourceId

      @Stability(Stable) @NotNull public static String contextResourceId()
      The identifier that API Gateway assigns to your resource.
    • contextResourcePath

      @Stability(Stable) @NotNull public static String contextResourcePath()
      The path to your resource.

      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.

      See Also:
    • contextResponseLatency

      @Stability(Stable) @NotNull public static String contextResponseLatency()
      The response latency in ms.
    • contextResponseLength

      @Stability(Stable) @NotNull public static String contextResponseLength()
      The response payload length.
    • contextResponseOverrideHeader

      @Stability(Stable) @NotNull public static String contextResponseOverrideHeader(@NotNull String headerName)
      The response header override.

      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.

      Parameters:
      headerName - This parameter is required.
      See Also:
    • contextResponseOverrideStatus

      @Stability(Stable) @NotNull public static String contextResponseOverrideStatus()
      The response status code override.

      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.

      See Also:
    • contextStage

      @Stability(Stable) @NotNull public static String contextStage()
      The deployment stage of the API request (for example, Beta or Prod).
    • contextStatus

      @Stability(Stable) @NotNull public static String contextStatus()
      The method response status.
    • contextWafError

      @Stability(Stable) @NotNull public static String contextWafError()
      The error message returned from AWS WAF.
    • contextWafLatency

      @Stability(Stable) @NotNull public static String contextWafLatency()
      The AWS WAF latency in ms.
    • contextWafResponseCode

      @Stability(Stable) @NotNull public static String contextWafResponseCode()
      The response received from AWS WAF: WAF_ALLOW or WAF_BLOCK.

      Will not be set if the stage is not associated with a web ACL.

      See Also:
    • contextWafStatus

      @Stability(Stable) @NotNull public static String contextWafStatus()
      The status code returned from AWS WAF.
    • contextWebaclArn

      @Stability(Stable) @NotNull public static String contextWebaclArn()
      The complete ARN of the web ACL that is used to decide whether to allow or block the request.

      Will not be set if the stage is not associated with a web ACL.

      See Also:
    • contextXrayTraceId

      @Stability(Stable) @NotNull public static String contextXrayTraceId()
      The trace ID for the X-Ray trace.

      See Also: