Class AccessLogField
- Namespace
- Amazon.CDK.AWS.APIGateway
- Assembly
- Amazon.CDK.AWS.APIGateway.dll
$context variables that can be used to customize access log pattern.
public class AccessLogField : DeputyBase
- Inheritance
-
AccessLogField
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")
} }
}));
Remarks
ExampleMetadata: infused
Constructors
AccessLogField()
public AccessLogField()
Methods
ContextAccountId()
The API owner's AWS account ID.
public static string ContextAccountId()
Returns
ContextApiId()
The identifier API Gateway assigns to your API.
public static string ContextApiId()
Returns
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
stringkey of the context map.
Returns
Remarks
See: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
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
stringA property key of the claims.
Returns
Remarks
See: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate-with-cognito.html
ContextAuthorizerIntegrationLatency()
The authorizer latency in ms.
public static string ContextAuthorizerIntegrationLatency()
Returns
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
Remarks
See: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
ContextAwsEndpointRequestId()
The AWS endpoint's request ID.
public static string ContextAwsEndpointRequestId()
Returns
ContextDomainName()
The full domain name used to invoke the API.
public static string ContextDomainName()
Returns
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
ContextErrorMessage()
A string containing an API Gateway error message.
public static string ContextErrorMessage()
Returns
ContextErrorMessageString()
The quoted value of $context.error.message, namely "$context.error.message".
public static string ContextErrorMessageString()
Returns
ContextErrorResponseType()
A type of GatewayResponse.
public static string ContextErrorResponseType()
Returns
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
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
ContextHttpMethod()
The HTTP method used.
public static string ContextHttpMethod()
Returns
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
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
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
ContextIdentityCaller()
The principal identifier of the caller making the request.
public static string ContextIdentityCaller()
Returns
ContextIdentityCognitoAuthenticationProvider()
The Amazon Cognito authentication provider used by the caller making the request.
public static string ContextIdentityCognitoAuthenticationProvider()
Returns
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
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
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
Remarks
Available only if the request was signed with Amazon Cognito credentials.
ContextIdentityPrincipalOrgId()
The AWS organization ID.
public static string ContextIdentityPrincipalOrgId()
Returns
ContextIdentitySourceIp()
The source IP address of the TCP connection making the request to API Gateway.
public static string ContextIdentitySourceIp()
Returns
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
Remarks
Used in Lambda authorizers.
ContextIdentityUserAgent()
The User-Agent header of the API caller.
public static string ContextIdentityUserAgent()
Returns
ContextIdentityUserArn()
The Amazon Resource Name (ARN) of the effective user identified after authentication.
public static string ContextIdentityUserArn()
Returns
Remarks
ContextIntegrationLatency()
The integration latency in ms.
public static string ContextIntegrationLatency()
Returns
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
ContextPath()
The request path.
public static string ContextPath()
Returns
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
ContextRequestId()
The ID that API Gateway assigns to the API request.
public static string ContextRequestId()
Returns
ContextRequestOverrideHeader(string)
The request header override.
public static string ContextRequestOverrideHeader(string headerName)
Parameters
headerName
string
Returns
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
string
Returns
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
string
Returns
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
ContextRequestTimeEpoch()
The Epoch-formatted request time.
public static string ContextRequestTimeEpoch()
Returns
ContextResourceId()
The identifier that API Gateway assigns to your resource.
public static string ContextResourceId()
Returns
ContextResourcePath()
The path to your resource.
public static string ContextResourcePath()
Returns
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
ContextResponseLength()
The response payload length.
public static string ContextResponseLength()
Returns
ContextResponseOverrideHeader(string)
The response header override.
public static string ContextResponseOverrideHeader(string headerName)
Parameters
headerName
string
Returns
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
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
ContextStatus()
The method response status.
public static string ContextStatus()
Returns
ContextWafResponseCode()
The response received from AWS WAF: WAF_ALLOW
or WAF_BLOCK
.
public static string ContextWafResponseCode()
Returns
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
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
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()