marcodaniels/elm-aws-cloudfront/1.0.0

CloudFront.Lambda

Edge@Lambda handlers for AWS CloudFront request and response events.

Read more about Edge@Lambda event structure.

Handlers

(OriginRequest -> flags -> OutputEvent)
-> flags
-> Maybe InputOrigin

Handler for origin request events

originRequest
    (\{ request } flags ->
        { request | uri = "new-uri" }
            |> toRequest
    )
(OriginResponse -> flags -> OutputEvent)
-> flags
-> Maybe InputOrigin

Handler for origin response events

originResponse
    (\{ response, request } _ ->
        response
            |> withHeader
                { key = "cache-control", value = "public, max-age=31536000" }
            |> toResponse
    )

Output

toRequest : Request -> OutputEvent

Map request to output event, to be used with originRequest or originResponse

toResponse : Response -> OutputEvent

Map response to output event, to be used with originResponse

Types

Types for the lambda event structure.

type alias InputEvent =
{ records : List Record }
type alias Record =
{ cf : InputOrigin }
= InputResponse OriginResponse
| InputRequest OriginRequest
type alias OriginResponse =
{ config : Config
, request : Request
, response : Response
}
type alias OriginRequest =
{ config : Config
, request : Request
}
type alias Config =
{ distributionDomainName : String
, distributionId : String
, eventType : String
, requestId : String
}
type alias Request =
{ clientIp : String
, headers : Headers
, method : String
, origin : Origin
, querystring : Maybe String
, uri : String
}
type alias Response =
{ status : String
, statusDescription : String
, headers : Headers
}
type Origin
= OriginS3 S3Origin
| OriginCustom CustomOrigin
| OriginUnknown
type alias S3Origin =
{ s3 : S3OriginData }
type alias S3OriginData =
{ authMethod : String
, customHeaders : Headers
, domainName : String
, path : String
, region : String
}
type alias CustomOrigin =
{ custom : CustomOriginData }
type alias CustomOriginData =
{ customHeaders : Headers
, domainName : String
, keepaliveTimeout : Int
, path : String
, port_ : Int
, protocol : String
, readTimeout : Int
, sslProtocols : List String
}
= OutputResponse Response
| OutputRequest Request