class AccessLogField
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGateway.AccessLogField |
Java | software.amazon.awscdk.services.apigateway.AccessLogField |
Python | aws_cdk.aws_apigateway.AccessLogField |
TypeScript (source) | @aws-cdk/aws-apigateway » AccessLogField |
$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')
}
}))
Initializer
new AccessLogField()
Methods
Name | Description |
---|---|
static context | The API owner's AWS account ID. |
static context | The identifier API Gateway assigns to your API. |
static context | The stringified value of the specified key-value pair of the context map returned from an API Gateway Lambda authorizer function. |
static context | A property of the claims returned from the Amazon Cognito user pool after the method caller is successfully authenticated. |
static context | The authorizer latency in ms. |
static context | 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). |
static context | The AWS endpoint's request ID. |
static context | The full domain name used to invoke the API. |
static context | The first label of the $context.domainName . This is often used as a caller/customer identifier. |
static context | A string containing an API Gateway error message. |
static context | The quoted value of $context.error.message, namely "$context.error.message". |
static context | A type of GatewayResponse. |
static context | A string containing a detailed validation error message. |
static context | The extended ID that API Gateway assigns to the API request, which contains more useful information for debugging/troubleshooting. |
static context | The HTTP method used. |
static context | The AWS account ID associated with the request. |
static context | For API methods that require an API key, this variable is the API key associated with the method request. |
static context | The API key ID associated with an API request that requires an API key. |
static context | The principal identifier of the caller making the request. |
static context | The Amazon Cognito authentication provider used by the caller making the request. |
static context | The Amazon Cognito authentication type of the caller making the request. |
static context | The Amazon Cognito identity ID of the caller making the request. |
static context | The Amazon Cognito identity pool ID of the caller making the request. |
static context | The AWS organization ID. |
static context | The source IP address of the TCP connection making the request to API Gateway. |
static context | The principal identifier of the user making the request. |
static context | The User-Agent header of the API caller. |
static context | The Amazon Resource Name (ARN) of the effective user identified after authentication. |
static context | The integration latency in ms. |
static context | For Lambda proxy integration, this parameter represents the status code returned from AWS Lambda, not from the backend Lambda function. |
static context | The request path. |
static context | The request protocol, for example, HTTP/1.1. |
static context | The ID that API Gateway assigns to the API request. |
static context | The request header override. |
static context | The request path override. |
static context | The request query string override. |
static context | The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm). |
static context | The Epoch-formatted request time. |
static context | The identifier that API Gateway assigns to your resource. |
static context | The path to your resource. |
static context | The response latency in ms. |
static context | The response payload length. |
static context | The response header override. |
static context | The response status code override. |
static context | The deployment stage of the API request (for example, Beta or Prod ). |
static context | The method response status. |
static context | The response received from AWS WAF: WAF_ALLOW or WAF_BLOCK . |
static context | The complete ARN of the web ACL that is used to decide whether to allow or block the request. |
static context | The trace ID for the X-Ray trace. |
AccountId()
static contextpublic static contextAccountId(): string
Returns
string
The API owner's AWS account ID.
ApiId()
static contextpublic static contextApiId(): string
Returns
string
The identifier API Gateway assigns to your API.
Authorizer(property)
static contextpublic static contextAuthorizer(property: string): string
Parameters
- property
string
— key of the context map.
Returns
string
The stringified value of the specified key-value pair of the context
map returned from an API Gateway Lambda authorizer function.
AuthorizerClaims(property)
static contextpublic static contextAuthorizerClaims(property: string): string
Parameters
- property
string
— A property key of the claims.
Returns
string
A property of the claims returned from the Amazon Cognito user pool after the method caller is successfully authenticated.
AuthorizerIntegrationLatency()
static contextpublic static contextAuthorizerIntegrationLatency(): string
Returns
string
The authorizer latency in ms.
AuthorizerPrincipalId()
static contextpublic static contextAuthorizerPrincipalId(): string
Returns
string
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).
AwsEndpointRequestId()
static contextpublic static contextAwsEndpointRequestId(): string
Returns
string
The AWS endpoint's request ID.
DomainName()
static contextpublic static contextDomainName(): string
Returns
string
The full domain name used to invoke the API.
This should be the same as the incoming Host
header.
DomainPrefix()
static contextpublic static contextDomainPrefix(): string
Returns
string
The first label of the $context.domainName
. This is often used as a caller/customer identifier.
ErrorMessage()
static contextpublic static contextErrorMessage(): string
Returns
string
A string containing an API Gateway error message.
ErrorMessageString()
static contextpublic static contextErrorMessageString(): string
Returns
string
The quoted value of $context.error.message, namely "$context.error.message".
ErrorResponseType()
static contextpublic static contextErrorResponseType(): string
Returns
string
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.
ErrorValidationErrorString()
static contextpublic static contextErrorValidationErrorString(): string
Returns
string
A string containing a detailed validation error message.
ExtendedRequestId()
static contextpublic static contextExtendedRequestId(): string
Returns
string
The extended ID that API Gateway assigns to the API request, which contains more useful information for debugging/troubleshooting.
HttpMethod()
static contextpublic static contextHttpMethod(): string
Returns
string
The HTTP method used.
Valid values include: DELETE
, GET
, HEAD
, OPTIONS
, PATCH
, POST
, and PUT
.
IdentityAccountId()
static contextpublic static contextIdentityAccountId(): string
Returns
string
The AWS account ID associated with the request.
IdentityApiKey()
static contextpublic static contextIdentityApiKey(): string
Returns
string
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
IdentityApiKeyId()
static contextpublic static contextIdentityApiKeyId(): string
Returns
string
The API key ID associated with an API request that requires an API key.
IdentityCaller()
static contextpublic static contextIdentityCaller(): string
Returns
string
The principal identifier of the caller making the request.
IdentityCognitoAuthenticationProvider()
static contextpublic static contextIdentityCognitoAuthenticationProvider(): string
Returns
string
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: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html
IdentityCognitoAuthenticationType()
static contextpublic static contextIdentityCognitoAuthenticationType(): string
Returns
string
The Amazon Cognito authentication type of the caller making the request.
Available only if the request was signed with Amazon Cognito credentials.
IdentityCognitoIdentityId()
static contextpublic static contextIdentityCognitoIdentityId(): string
Returns
string
The Amazon Cognito identity ID of the caller making the request.
Available only if the request was signed with Amazon Cognito credentials.
IdentityCognitoIdentityPoolId()
static contextpublic static contextIdentityCognitoIdentityPoolId(): string
Returns
string
The Amazon Cognito identity pool ID of the caller making the request.
Available only if the request was signed with Amazon Cognito credentials.
IdentityPrincipalOrgId()
static contextpublic static contextIdentityPrincipalOrgId(): string
Returns
string
The AWS organization ID.
IdentitySourceIp()
static contextpublic static contextIdentitySourceIp(): string
Returns
string
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.
IdentityUser()
static contextpublic static contextIdentityUser(): string
Returns
string
The principal identifier of the user making the request.
Used in Lambda authorizers.
IdentityUserAgent()
static contextpublic static contextIdentityUserAgent(): string
Returns
string
The User-Agent header of the API caller.
IdentityUserArn()
static contextpublic static contextIdentityUserArn(): string
Returns
string
The Amazon Resource Name (ARN) of the effective user identified after authentication.
See also: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html
IntegrationLatency()
static contextpublic static contextIntegrationLatency(): string
Returns
string
The integration latency in ms.
IntegrationStatus()
static contextpublic static contextIntegrationStatus(): string
Returns
string
For Lambda proxy integration, this parameter represents the status code returned from AWS Lambda, not from the backend Lambda function.
Path()
static contextpublic static contextPath(): string
Returns
string
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.
Protocol()
static contextpublic static contextProtocol(): string
Returns
string
The request protocol, for example, HTTP/1.1.
RequestId()
static contextpublic static contextRequestId(): string
Returns
string
The ID that API Gateway assigns to the API request.
RequestOverrideHeader(headerName)
static contextpublic static contextRequestOverrideHeader(headerName: string): string
Parameters
- headerName
string
Returns
string
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.
RequestOverridePath(pathName)
static contextpublic static contextRequestOverridePath(pathName: string): string
Parameters
- pathName
string
Returns
string
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.
RequestOverrideQuerystring(querystringName)
static contextpublic static contextRequestOverrideQuerystring(querystringName: string): string
Parameters
- querystringName
string
Returns
string
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.
RequestTime()
static contextpublic static contextRequestTime(): string
Returns
string
The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
RequestTimeEpoch()
static contextpublic static contextRequestTimeEpoch(): string
Returns
string
The Epoch-formatted request time.
ResourceId()
static contextpublic static contextResourceId(): string
Returns
string
The identifier that API Gateway assigns to your resource.
ResourcePath()
static contextpublic static contextResourcePath(): string
Returns
string
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
.
ResponseLatency()
static contextpublic static contextResponseLatency(): string
Returns
string
The response latency in ms.
ResponseLength()
static contextpublic static contextResponseLength(): string
Returns
string
The response payload length.
ResponseOverrideHeader(headerName)
static contextpublic static contextResponseOverrideHeader(headerName: string): string
Parameters
- headerName
string
Returns
string
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.
ResponseOverrideStatus()
static contextpublic static contextResponseOverrideStatus(): string
Returns
string
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.
Stage()
static contextpublic static contextStage(): string
Returns
string
The deployment stage of the API request (for example, Beta
or Prod
).
Status()
static contextpublic static contextStatus(): string
Returns
string
The method response status.
WafResponseCode()
static contextpublic static contextWafResponseCode(): string
Returns
string
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.
WebaclArn()
static contextpublic static contextWebaclArn(): string
Returns
string
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.
XrayTraceId()
static contextpublic static contextXrayTraceId(): string
Returns
string
The trace ID for the X-Ray trace.