AccessLogField Class
$context variables that can be used to customize access log pattern.
| Source | aws-apigateway/lib/access-log.ts |
|---|---|
| Type last changed |
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() *string static deprecated #contextApiId(): string@staticmethod def context_api_id() -> strpublic static String contextApiId()public static string ContextApiId()func ContextApiId() *string static #contextAuthenticateError(): string@staticmethod def context_authenticate_error() -> strpublic static String contextAuthenticateError()public static string ContextAuthenticateError()func ContextAuthenticateError() *string static #contextAuthenticateLatency(): string@staticmethod def context_authenticate_latency() -> strpublic static String contextAuthenticateLatency()public static string ContextAuthenticateLatency()func ContextAuthenticateLatency() *string static #contextAuthenticateStatus(): string@staticmethod def context_authenticate_status() -> strpublic static String contextAuthenticateStatus()public static string ContextAuthenticateStatus()func ContextAuthenticateStatus() *string static #contextAuthorizeError(): string@staticmethod def context_authorize_error() -> strpublic static String contextAuthorizeError()public static string ContextAuthorizeError()func ContextAuthorizeError() *string static #contextAuthorizeLatency(): string@staticmethod def context_authorize_latency() -> strpublic static String contextAuthorizeLatency()public static string ContextAuthorizeLatency()func ContextAuthorizeLatency() *string static #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) *string static #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) *string static #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() *string static #contextAuthorizerIntegrationLatency(): string@staticmethod def context_authorizer_integration_latency() -> strpublic static String contextAuthorizerIntegrationLatency()public static string ContextAuthorizerIntegrationLatency()func ContextAuthorizerIntegrationLatency() *string static #contextAuthorizerIntegrationStatus(): string@staticmethod def context_authorizer_integration_status() -> strpublic static String contextAuthorizerIntegrationStatus()public static string ContextAuthorizerIntegrationStatus()func ContextAuthorizerIntegrationStatus() *string static #contextAuthorizerLatency(): string@staticmethod def context_authorizer_latency() -> strpublic static String contextAuthorizerLatency()public static string ContextAuthorizerLatency()func ContextAuthorizerLatency() *string static #contextAuthorizerPrincipalId(): string@staticmethod def context_authorizer_principal_id() -> strpublic static String contextAuthorizerPrincipalId()public static string ContextAuthorizerPrincipalId()func ContextAuthorizerPrincipalId() *string static #contextAuthorizerRequestId(): string@staticmethod def context_authorizer_request_id() -> strpublic static String contextAuthorizerRequestId()public static string ContextAuthorizerRequestId()func ContextAuthorizerRequestId() *string static #contextAuthorizerStatus(): string@staticmethod def context_authorizer_status() -> strpublic static String contextAuthorizerStatus()public static string ContextAuthorizerStatus()func ContextAuthorizerStatus() *string static #contextAuthorizeStatus(): string@staticmethod def context_authorize_status() -> strpublic static String contextAuthorizeStatus()public static string ContextAuthorizeStatus()func ContextAuthorizeStatus() *string static #contextAwsEndpointRequestId(): string@staticmethod def context_aws_endpoint_request_id() -> strpublic static String contextAwsEndpointRequestId()public static string ContextAwsEndpointRequestId()func ContextAwsEndpointRequestId() *string static #contextCallerAccountId(): string@staticmethod def context_caller_account_id() -> strpublic static String contextCallerAccountId()public static string ContextCallerAccountId()func ContextCallerAccountId() *string static #contextConnectionId(): string@staticmethod def context_connection_id() -> strpublic static String contextConnectionId()public static string ContextConnectionId()func ContextConnectionId() *string static #contextCustomDomainBasePathMatched(): string@staticmethod def context_custom_domain_base_path_matched() -> strpublic static String contextCustomDomainBasePathMatched()public static string ContextCustomDomainBasePathMatched()func ContextCustomDomainBasePathMatched() *string static #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() *string static #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() *string static #contextErrorMessage(): string@staticmethod def context_error_message() -> strpublic static String contextErrorMessage()public static string ContextErrorMessage()func ContextErrorMessage() *string static #contextErrorMessageString(): string@staticmethod def context_error_message_string() -> strpublic static String contextErrorMessageString()public static string ContextErrorMessageString()func ContextErrorMessageString() *string static #contextErrorResponseType(): string@staticmethod def context_error_response_type() -> strpublic static String contextErrorResponseType()public static string ContextErrorResponseType()func ContextErrorResponseType() *string static #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() *string static #contextEventType(): string@staticmethod def context_event_type() -> strpublic static String contextEventType()public static string ContextEventType()func ContextEventType() *string static #contextExtendedRequestId(): string@staticmethod def context_extended_request_id() -> strpublic static String contextExtendedRequestId()public static string ContextExtendedRequestId()func ContextExtendedRequestId() *string static #contextHttpMethod(): string@staticmethod def context_http_method() -> strpublic static String contextHttpMethod()public static string ContextHttpMethod()func ContextHttpMethod() *string static #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() *string static #contextIdentityApiKey(): string@staticmethod def context_identity_api_key() -> strpublic static String contextIdentityApiKey()public static string ContextIdentityApiKey()func ContextIdentityApiKey() *string static #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() *string static #contextIdentityCaller(): string@staticmethod def context_identity_caller() -> strpublic static String contextIdentityCaller()public static string ContextIdentityCaller()func ContextIdentityCaller() *string static #contextIdentityClientCertIssunerDN(): string@staticmethod def context_identity_client_cert_issuner_dn() -> strpublic static String contextIdentityClientCertIssunerDN()public static string ContextIdentityClientCertIssunerDN()func ContextIdentityClientCertIssunerDN() *string static #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() *string static #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() *string static #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() *string static #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() *string static #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() *string static #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() *string static #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() *string static #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() *string static #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() *string static #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() *string static #contextIdentitySourceIp(): string@staticmethod def context_identity_source_ip() -> strpublic static String contextIdentitySourceIp()public static string ContextIdentitySourceIp()func ContextIdentitySourceIp() *string static #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() *string static #Used in Lambda authorizers.
contextIdentityUserAgent(): string@staticmethod def context_identity_user_agent() -> strpublic static String contextIdentityUserAgent()public static string ContextIdentityUserAgent()func ContextIdentityUserAgent() *string static #contextIdentityUserArn(): string@staticmethod def context_identity_user_arn() -> strpublic static String contextIdentityUserArn()public static string ContextIdentityUserArn()func ContextIdentityUserArn() *string static #contextIntegrationErrorMessage(): string@staticmethod def context_integration_error_message() -> strpublic static String contextIntegrationErrorMessage()public static string ContextIntegrationErrorMessage()func ContextIntegrationErrorMessage() *string static #contextIntegrationLatency(): string@staticmethod def context_integration_latency() -> strpublic static String contextIntegrationLatency()public static string ContextIntegrationLatency()func ContextIntegrationLatency() *string static #contextIntegrationStatus(): string@staticmethod def context_integration_status() -> strpublic static String contextIntegrationStatus()public static string ContextIntegrationStatus()func ContextIntegrationStatus() *string static #contextOwnerAccountId(): string@staticmethod def context_owner_account_id() -> strpublic static String contextOwnerAccountId()public static string ContextOwnerAccountId()func ContextOwnerAccountId() *string static #contextPath(): string@staticmethod def context_path() -> strpublic static String contextPath()public static string ContextPath()func ContextPath() *string static #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() *string static #contextRequestId(): string@staticmethod def context_request_id() -> strpublic static String contextRequestId()public static string ContextRequestId()func ContextRequestId() *string static #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) *string static #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) *string static #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) *string static #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() *string static #contextRequestTimeEpoch(): string@staticmethod def context_request_time_epoch() -> strpublic static String contextRequestTimeEpoch()public static string ContextRequestTimeEpoch()func ContextRequestTimeEpoch() *string static #contextResourceId(): string@staticmethod def context_resource_id() -> strpublic static String contextResourceId()public static string ContextResourceId()func ContextResourceId() *string static #contextResourcePath(): string@staticmethod def context_resource_path() -> strpublic static String contextResourcePath()public static string ContextResourcePath()func ContextResourcePath() *string static #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() *string static #contextResponseLength(): string@staticmethod def context_response_length() -> strpublic static String contextResponseLength()public static string ContextResponseLength()func ContextResponseLength() *string static #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) *string static #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() *string static #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() *string static #contextStage(): string@staticmethod def context_stage() -> strpublic static String contextStage()public static string ContextStage()func ContextStage() *string static #contextStatus(): string@staticmethod def context_status() -> strpublic static String contextStatus()public static string ContextStatus()func ContextStatus() *string static #contextWafError(): string@staticmethod def context_waf_error() -> strpublic static String contextWafError()public static string ContextWafError()func ContextWafError() *string static #contextWafLatency(): string@staticmethod def context_waf_latency() -> strpublic static String contextWafLatency()public static string ContextWafLatency()func ContextWafLatency() *string static #contextWafResponseCode(): string@staticmethod def context_waf_response_code() -> strpublic static String contextWafResponseCode()public static string ContextWafResponseCode()func ContextWafResponseCode() *string static #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() *string static #contextWebaclArn(): string@staticmethod def context_webacl_arn() -> strpublic static String contextWebaclArn()public static string ContextWebaclArn()func ContextWebaclArn() *string static #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() *string static #