Class AccessLogField
$context variables that can be used to customize access log pattern.
Inheritance
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class AccessLogField : DeputyBase
Syntax (vb)
Public Class AccessLogField
Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
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")
} }
}));
Synopsis
Constructors
AccessLogField() | |
AccessLogField(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
AccessLogField(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
ContextAccountId() | (deprecated) The API callers AWS account ID. |
ContextApiId() | The identifier API Gateway assigns to your API. |
ContextAuthenticateError() | The error message returned from an authentication attempt. |
ContextAuthenticateLatency() | The authentication latency in ms. |
ContextAuthenticateStatus() | The status code returned from an authentication attempt. |
ContextAuthorizeError() | The authorization error message. |
ContextAuthorizeLatency() | The authorization latency in ms. |
ContextAuthorizer(String) | The stringified value of the specified key-value pair of the |
ContextAuthorizerClaims(String) | A property of the claims returned from the Amazon Cognito user pool after the method caller is successfully authenticated. |
ContextAuthorizerError() | The error message returned from an authorizer. |
ContextAuthorizerIntegrationLatency() | The authorizer latency in ms. |
ContextAuthorizerIntegrationStatus() | The status code returned from a Lambda authorizer. |
ContextAuthorizerLatency() | The authorizer latency in ms. |
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). |
ContextAuthorizerRequestId() | The AWS endpoint's request ID. |
ContextAuthorizerStatus() | The status code returned from an authorizer. |
ContextAuthorizeStatus() | The status code returned from an authorization attempt. |
ContextAwsEndpointRequestId() | The AWS endpoint's request ID. |
ContextCallerAccountId() | The API callers AWS account ID. |
ContextCustomDomainBasePathMatched() | The path for an API mapping that an incoming request matched. |
ContextDomainName() | The full domain name used to invoke the API. |
ContextDomainPrefix() | The first label of the |
ContextErrorMessage() | A string containing an API Gateway error message. |
ContextErrorMessageString() | The quoted value of $context.error.message, namely "$context.error.message". |
ContextErrorResponseType() | A type of GatewayResponse. |
ContextErrorValidationErrorString() | A string containing a detailed validation error message. |
ContextExtendedRequestId() | The extended ID that API Gateway assigns to the API request, which contains more useful information for debugging/troubleshooting. |
ContextHttpMethod() | The HTTP method used. |
ContextIdentityAccountId() | The AWS account ID associated with the request. |
ContextIdentityApiKey() | For API methods that require an API key, this variable is the API key associated with the method request. |
ContextIdentityApiKeyId() | The API key ID associated with an API request that requires an API key. |
ContextIdentityCaller() | The principal identifier of the caller making the request. |
ContextIdentityClientCertIssunerDN() | The distinguished name of the issuer of the certificate that a client presents. |
ContextIdentityClientCertPem() | The PEM-encoded client certificate that the client presented during mutual TLS authentication. |
ContextIdentityClientCertSerialNumber() | The serial number of the certificate. |
ContextIdentityClientCertSubjectDN() | The distinguished name of the subject of the certificate that a client presents. |
ContextIdentityClientCertValidityNotAfter() | The date after which the certificate is invalid. |
ContextIdentityClientCertValidityNotBefore() | The date before which the certificate is invalid. |
ContextIdentityCognitoAuthenticationProvider() | The Amazon Cognito authentication provider used by the caller making the request. |
ContextIdentityCognitoAuthenticationType() | The Amazon Cognito authentication type of the caller making the request. |
ContextIdentityCognitoIdentityId() | The Amazon Cognito identity ID of the caller making the request. |
ContextIdentityCognitoIdentityPoolId() | The Amazon Cognito identity pool ID of the caller making the request. |
ContextIdentityPrincipalOrgId() | The AWS organization ID. |
ContextIdentitySourceIp() | The source IP address of the TCP connection making the request to API Gateway. |
ContextIdentityUser() | The principal identifier of the user making the request. |
ContextIdentityUserAgent() | The User-Agent header of the API caller. |
ContextIdentityUserArn() | The Amazon Resource Name (ARN) of the effective user identified after authentication. |
ContextIntegrationErrorMessage() | A string that contains an integration error message. |
ContextIntegrationLatency() | The integration latency in ms. |
ContextIntegrationStatus() | For Lambda proxy integration, this parameter represents the status code returned from AWS Lambda, not from the backend Lambda function. |
ContextOwnerAccountId() | The API owner's AWS account ID. |
ContextPath() | The request path. |
ContextProtocol() | The request protocol, for example, HTTP/1.1. |
ContextRequestId() | The ID that API Gateway assigns to the API request. |
ContextRequestOverrideHeader(String) | The request header override. |
ContextRequestOverridePath(String) | The request path override. |
ContextRequestOverrideQuerystring(String) | The request query string override. |
ContextRequestTime() | The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm). |
ContextRequestTimeEpoch() | The Epoch-formatted request time. |
ContextResourceId() | The identifier that API Gateway assigns to your resource. |
ContextResourcePath() | The path to your resource. |
ContextResponseLatency() | The response latency in ms. |
ContextResponseLength() | The response payload length. |
ContextResponseOverrideHeader(String) | The response header override. |
ContextResponseOverrideStatus() | The response status code override. |
ContextStage() | The deployment stage of the API request (for example, |
ContextStatus() | The method response status. |
ContextWafError() | The error message returned from AWS WAF. |
ContextWafLatency() | The AWS WAF latency in ms. |
ContextWafResponseCode() | The response received from AWS WAF: |
ContextWafStatus() | The status code returned from AWS WAF. |
ContextWebaclArn() | The complete ARN of the web ACL that is used to decide whether to allow or block the request. |
ContextXrayTraceId() | The trace ID for the X-Ray trace. |
Constructors
AccessLogField()
public AccessLogField()
AccessLogField(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected AccessLogField(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
AccessLogField(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected AccessLogField(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
ContextAccountId()
(deprecated) The API callers AWS account ID.
public static string ContextAccountId()
Returns
System.String
Remarks
Stability: Deprecated
ContextApiId()
The identifier API Gateway assigns to your API.
public static string ContextApiId()
Returns
System.String
ContextAuthenticateError()
The error message returned from an authentication attempt.
public static string ContextAuthenticateError()
Returns
System.String
ContextAuthenticateLatency()
The authentication latency in ms.
public static string ContextAuthenticateLatency()
Returns
System.String
ContextAuthenticateStatus()
The status code returned from an authentication attempt.
public static string ContextAuthenticateStatus()
Returns
System.String
ContextAuthorizeError()
The authorization error message.
public static string ContextAuthorizeError()
Returns
System.String
ContextAuthorizeLatency()
The authorization latency in ms.
public static string ContextAuthorizeLatency()
Returns
System.String
ContextAuthorizer(String)
The stringified value of the specified key-value pair of the context
map returned from an API Gateway Lambda authorizer function.
public static string ContextAuthorizer(string property)
Parameters
- property System.String
key of the context map.
Returns
System.String
Remarks
ContextAuthorizerClaims(String)
A property of the claims returned from the Amazon Cognito user pool after the method caller is successfully authenticated.
public static string ContextAuthorizerClaims(string property)
Parameters
- property System.String
A property key of the claims.
Returns
System.String
Remarks
ContextAuthorizerError()
The error message returned from an authorizer.
public static string ContextAuthorizerError()
Returns
System.String
ContextAuthorizerIntegrationLatency()
The authorizer latency in ms.
public static string ContextAuthorizerIntegrationLatency()
Returns
System.String
ContextAuthorizerIntegrationStatus()
The status code returned from a Lambda authorizer.
public static string ContextAuthorizerIntegrationStatus()
Returns
System.String
ContextAuthorizerLatency()
The authorizer latency in ms.
public static string ContextAuthorizerLatency()
Returns
System.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).
public static string ContextAuthorizerPrincipalId()
Returns
System.String
Remarks
ContextAuthorizerRequestId()
The AWS endpoint's request ID.
public static string ContextAuthorizerRequestId()
Returns
System.String
ContextAuthorizerStatus()
The status code returned from an authorizer.
public static string ContextAuthorizerStatus()
Returns
System.String
ContextAuthorizeStatus()
The status code returned from an authorization attempt.
public static string ContextAuthorizeStatus()
Returns
System.String
ContextAwsEndpointRequestId()
The AWS endpoint's request ID.
public static string ContextAwsEndpointRequestId()
Returns
System.String
ContextCallerAccountId()
The API callers AWS account ID.
public static string ContextCallerAccountId()
Returns
System.String
ContextCustomDomainBasePathMatched()
The path for an API mapping that an incoming request matched.
public static string ContextCustomDomainBasePathMatched()
Returns
System.String
Remarks
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: https://docs.aws.amazon.com/en_jp/apigateway/latest/developerguide/rest-api-mappings.html
ContextDomainName()
The full domain name used to invoke the API.
public static string ContextDomainName()
Returns
System.String
Remarks
This should be the same as the incoming Host
header.
ContextDomainPrefix()
The first label of the $context.domainName
. This is often used as a caller/customer identifier.
public static string ContextDomainPrefix()
Returns
System.String
ContextErrorMessage()
A string containing an API Gateway error message.
public static string ContextErrorMessage()
Returns
System.String
ContextErrorMessageString()
The quoted value of $context.error.message, namely "$context.error.message".
public static string ContextErrorMessageString()
Returns
System.String
ContextErrorResponseType()
A type of GatewayResponse.
public static string ContextErrorResponseType()
Returns
System.String
Remarks
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: https://docs.aws.amazon.com/apigateway/latest/developerguide/customize-gateway-responses.html
ContextErrorValidationErrorString()
A string containing a detailed validation error message.
public static string ContextErrorValidationErrorString()
Returns
System.String
ContextExtendedRequestId()
The extended ID that API Gateway assigns to the API request, which contains more useful information for debugging/troubleshooting.
public static string ContextExtendedRequestId()
Returns
System.String
ContextHttpMethod()
The HTTP method used.
public static string ContextHttpMethod()
Returns
System.String
Remarks
Valid values include: DELETE
, GET
, HEAD
, OPTIONS
, PATCH
, POST
, and PUT
.
ContextIdentityAccountId()
The AWS account ID associated with the request.
public static string ContextIdentityAccountId()
Returns
System.String
ContextIdentityApiKey()
For API methods that require an API key, this variable is the API key associated with the method request.
public static string ContextIdentityApiKey()
Returns
System.String
Remarks
For methods that don't require an API key, this variable is
See: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html
ContextIdentityApiKeyId()
The API key ID associated with an API request that requires an API key.
public static string ContextIdentityApiKeyId()
Returns
System.String
ContextIdentityCaller()
The principal identifier of the caller making the request.
public static string ContextIdentityCaller()
Returns
System.String
ContextIdentityClientCertIssunerDN()
The distinguished name of the issuer of the certificate that a client presents.
public static string ContextIdentityClientCertIssunerDN()
Returns
System.String
Remarks
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()
The PEM-encoded client certificate that the client presented during mutual TLS authentication.
public static string ContextIdentityClientCertPem()
Returns
System.String
Remarks
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()
The serial number of the certificate.
public static string ContextIdentityClientCertSerialNumber()
Returns
System.String
Remarks
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()
The distinguished name of the subject of the certificate that a client presents.
public static string ContextIdentityClientCertSubjectDN()
Returns
System.String
Remarks
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()
The date after which the certificate is invalid.
public static string ContextIdentityClientCertValidityNotAfter()
Returns
System.String
Remarks
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()
The date before which the certificate is invalid.
public static string ContextIdentityClientCertValidityNotBefore()
Returns
System.String
Remarks
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()
The Amazon Cognito authentication provider used by the caller making the request.
public static string ContextIdentityCognitoAuthenticationProvider()
Returns
System.String
Remarks
Available only if the request was signed with Amazon Cognito credentials.
See: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html
ContextIdentityCognitoAuthenticationType()
The Amazon Cognito authentication type of the caller making the request.
public static string ContextIdentityCognitoAuthenticationType()
Returns
System.String
Remarks
Available only if the request was signed with Amazon Cognito credentials.
ContextIdentityCognitoIdentityId()
The Amazon Cognito identity ID of the caller making the request.
public static string ContextIdentityCognitoIdentityId()
Returns
System.String
Remarks
Available only if the request was signed with Amazon Cognito credentials.
ContextIdentityCognitoIdentityPoolId()
The Amazon Cognito identity pool ID of the caller making the request.
public static string ContextIdentityCognitoIdentityPoolId()
Returns
System.String
Remarks
Available only if the request was signed with Amazon Cognito credentials.
ContextIdentityPrincipalOrgId()
The AWS organization ID.
public static string ContextIdentityPrincipalOrgId()
Returns
System.String
ContextIdentitySourceIp()
The source IP address of the TCP connection making the request to API Gateway.
public static string ContextIdentitySourceIp()
Returns
System.String
Remarks
Warning: You should not trust this value if there is any chance that the X-Forwarded-For
header could be forged.
ContextIdentityUser()
The principal identifier of the user making the request.
public static string ContextIdentityUser()
Returns
System.String
Remarks
Used in Lambda authorizers.
ContextIdentityUserAgent()
The User-Agent header of the API caller.
public static string ContextIdentityUserAgent()
Returns
System.String
ContextIdentityUserArn()
The Amazon Resource Name (ARN) of the effective user identified after authentication.
public static string ContextIdentityUserArn()
Returns
System.String
Remarks
ContextIntegrationErrorMessage()
A string that contains an integration error message.
public static string ContextIntegrationErrorMessage()
Returns
System.String
ContextIntegrationLatency()
The integration latency in ms.
public static string ContextIntegrationLatency()
Returns
System.String
ContextIntegrationStatus()
For Lambda proxy integration, this parameter represents the status code returned from AWS Lambda, not from the backend Lambda function.
public static string ContextIntegrationStatus()
Returns
System.String
ContextOwnerAccountId()
The API owner's AWS account ID.
public static string ContextOwnerAccountId()
Returns
System.String
ContextPath()
The request path.
public static string ContextPath()
Returns
System.String
Remarks
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()
The request protocol, for example, HTTP/1.1.
public static string ContextProtocol()
Returns
System.String
ContextRequestId()
The ID that API Gateway assigns to the API request.
public static string ContextRequestId()
Returns
System.String
ContextRequestOverrideHeader(String)
The request header override.
public static string ContextRequestOverrideHeader(string headerName)
Parameters
- headerName System.String
Returns
System.String
Remarks
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(String)
The request path override.
public static string ContextRequestOverridePath(string pathName)
Parameters
- pathName System.String
Returns
System.String
Remarks
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(String)
The request query string override.
public static string ContextRequestOverrideQuerystring(string querystringName)
Parameters
- querystringName System.String
Returns
System.String
Remarks
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()
The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
public static string ContextRequestTime()
Returns
System.String
ContextRequestTimeEpoch()
The Epoch-formatted request time.
public static string ContextRequestTimeEpoch()
Returns
System.String
ContextResourceId()
The identifier that API Gateway assigns to your resource.
public static string ContextResourceId()
Returns
System.String
ContextResourcePath()
The path to your resource.
public static string ContextResourcePath()
Returns
System.String
Remarks
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()
The response latency in ms.
public static string ContextResponseLatency()
Returns
System.String
ContextResponseLength()
The response payload length.
public static string ContextResponseLength()
Returns
System.String
ContextResponseOverrideHeader(String)
The response header override.
public static string ContextResponseOverrideHeader(string headerName)
Parameters
- headerName System.String
Returns
System.String
Remarks
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()
The response status code override.
public static string ContextResponseOverrideStatus()
Returns
System.String
Remarks
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.
ContextStage()
The deployment stage of the API request (for example, Beta
or Prod
).
public static string ContextStage()
Returns
System.String
ContextStatus()
The method response status.
public static string ContextStatus()
Returns
System.String
ContextWafError()
The error message returned from AWS WAF.
public static string ContextWafError()
Returns
System.String
ContextWafLatency()
The AWS WAF latency in ms.
public static string ContextWafLatency()
Returns
System.String
ContextWafResponseCode()
The response received from AWS WAF: WAF_ALLOW
or WAF_BLOCK
.
public static string ContextWafResponseCode()
Returns
System.String
Remarks
Will not be set if the stage is not associated with a web ACL.
See: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-aws-waf.html
ContextWafStatus()
The status code returned from AWS WAF.
public static string ContextWafStatus()
Returns
System.String
ContextWebaclArn()
The complete ARN of the web ACL that is used to decide whether to allow or block the request.
public static string ContextWebaclArn()
Returns
System.String
Remarks
Will not be set if the stage is not associated with a web ACL.
See: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-aws-waf.html
ContextXrayTraceId()
The trace ID for the X-Ray trace.
public static string ContextXrayTraceId()
Returns
System.String