test_function¶
Operation¶
test_function
async
¶
test_function(input: TestFunctionInput, plugins: list[Plugin] | None = None) -> TestFunctionOutput
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 | Type | Description | Default |
|---|---|---|---|
input
|
TestFunctionInput
|
An instance of |
required |
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
Returns:
| Type | Description |
|---|---|
TestFunctionOutput
|
An instance of |
Input¶
TestFunctionInput
dataclass
¶
Bases: _SerdeShape
Dataclass for TestFunctionInput structure.
Attributes¶
event_object
class-attribute
instance-attribute
¶
event_object: bytes | None = ...
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.
if_match
class-attribute
instance-attribute
¶
if_match: str | None = ...
The current version (ETag value) of the function that you are testing,
which you can get using DescribeFunction.
Output¶
TestFunctionOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for TestFunctionOutput structure.
Attributes¶
response_metadata
class-attribute
instance-attribute
¶
Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.
test_result
class-attribute
instance-attribute
¶
An object that represents the result of running the function with the provided event object.