test_function
¶
test_function(
name: FunctionName,
if_match: string,
event_object: FunctionEventObject,
*,
config_overrides: Optional[CloudFrontClientConfig] = None,
stage: Optional[FunctionStage] = None,
) -> TestFunctionResult
Tests a CloudFront function.
To test a function, you provide an event object that represents an HTTP request or response that your CloudFront distribution could receive in production. CloudFront runs the function, passing it the event object that you provided, and returns the function's result (the modified event object) in the response. The response also contains function logs and error messages, if any exist. For more information about testing functions, see Testing functions in the Amazon CloudFront Developer Guide.
To test a function, you provide the function's name and version (ETag value) along with the event object. To get the function's name and version, you can use ListFunctions and DescribeFunction.
Parameters:
-
name(FunctionName) –The name of the function that you are testing.
-
if_match(string) –The current version (
ETagvalue) of the function that you are testing, which you can get usingDescribeFunction. -
stage(Optional[FunctionStage], default:None) –The stage of the function that you are testing, either
DEVELOPMENTorLIVE. -
event_object(FunctionEventObject) –The event object to test the function with. For more information about the structure of the event object, see Testing functions in the Amazon CloudFront Developer Guide.
Raises:
-
InvalidArgument–An argument is invalid.
-
InvalidIfMatchVersion–The
If-Matchversion is missing or not valid. -
NoSuchFunctionExists–The function does not exist.
-
TestFunctionFailed–The CloudFront function failed.
-
UnsupportedOperation–This operation is not supported in this Amazon Web Services Region.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_cloudfront/_services/cloud_front.py
8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 | |