Skip to content

Test Function

cloudfront_test_function R Documentation

Tests a CloudFront function

Description

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 list_functions and describe_function.

Usage

cloudfront_test_function(Name, IfMatch, Stage, EventObject)

Arguments

Name

[required] The name of the function that you are testing.

IfMatch

[required] The current version (ETag value) of the function that you are testing, which you can get using describe_function.

Stage

The stage of the function that you are testing, either DEVELOPMENT or LIVE.

EventObject

[required] 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.

Value

A list with the following syntax:

list(
  TestResult = list(
    FunctionSummary = list(
      Name = "string",
      Status = "string",
      FunctionConfig = list(
        Comment = "string",
        Runtime = "cloudfront-js-1.0"|"cloudfront-js-2.0",
        KeyValueStoreAssociations = list(
          Quantity = 123,
          Items = list(
            list(
              KeyValueStoreARN = "string"
            )
          )
        )
      ),
      FunctionMetadata = list(
        FunctionARN = "string",
        Stage = "DEVELOPMENT"|"LIVE",
        CreatedTime = as.POSIXct(
          "2015-01-01"
        ),
        LastModifiedTime = as.POSIXct(
          "2015-01-01"
        )
      )
    ),
    ComputeUtilization = "string",
    FunctionExecutionLogs = list(
      "string"
    ),
    FunctionErrorMessage = "string",
    FunctionOutput = "string"
  )
)

Request syntax

svc$test_function(
  Name = "string",
  IfMatch = "string",
  Stage = "DEVELOPMENT"|"LIVE",
  EventObject = raw
)