-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Deploying Haskell code onto AWS Lambda using Serverless -- -- Utilities to help process the events from AWS Lambda when deployed -- with the serverless-haskell plugin. @package serverless-haskell @version 0.10.4 module AWSLambda.Events.MessageAttribute data MessageAttribute MessageAttribute :: !Text -> !Text -> MessageAttribute [_maType] :: MessageAttribute -> !Text [_maValue] :: MessageAttribute -> !Text maValue :: Lens' MessageAttribute Text maType :: Lens' MessageAttribute Text instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.MessageAttribute.MessageAttribute instance GHC.Show.Show AWSLambda.Events.MessageAttribute.MessageAttribute instance GHC.Classes.Eq AWSLambda.Events.MessageAttribute.MessageAttribute module AWSLambda.Events.Records newtype RecordsEvent a RecordsEvent :: [a] -> RecordsEvent a [_reRecords] :: RecordsEvent a -> [a] reRecords :: forall a_akMr a_apW3. Iso (RecordsEvent a_akMr) (RecordsEvent a_apW3) [a_akMr] [a_apW3] instance GHC.Show.Show a => GHC.Show.Show (AWSLambda.Events.Records.RecordsEvent a) instance GHC.Classes.Eq a => GHC.Classes.Eq (AWSLambda.Events.Records.RecordsEvent a) instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (AWSLambda.Events.Records.RecordsEvent a) -- | Based on -- https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.KinesisEvents module AWSLambda.Events.KinesisEvent data KinesisRecord KinesisRecord :: !Record -> !Text -> KinesisRecord [_krRecord] :: KinesisRecord -> !Record [_krKinesisSchemaVersion] :: KinesisRecord -> !Text krRecord :: Lens' KinesisRecord Record krKinesisSchemaVersion :: Lens' KinesisRecord Text data KinesisEventRecord KinesisEventRecord :: !KinesisRecord -> !Text -> !Text -> !Text -> !Text -> !Text -> !Text -> !Region -> KinesisEventRecord [_kerKinesis] :: KinesisEventRecord -> !KinesisRecord [_kerEventSource] :: KinesisEventRecord -> !Text [_kerEventID] :: KinesisEventRecord -> !Text [_kerInvokeIdentityArn] :: KinesisEventRecord -> !Text [_kerEventVersion] :: KinesisEventRecord -> !Text [_kerEventName] :: KinesisEventRecord -> !Text [_kerEventSourceARN] :: KinesisEventRecord -> !Text [_kerAwsRegion] :: KinesisEventRecord -> !Region kerKinesis :: Lens' KinesisEventRecord KinesisRecord kerInvokeIdentityArn :: Lens' KinesisEventRecord Text kerEventVersion :: Lens' KinesisEventRecord Text kerEventSourceARN :: Lens' KinesisEventRecord Text kerEventSource :: Lens' KinesisEventRecord Text kerEventName :: Lens' KinesisEventRecord Text kerEventID :: Lens' KinesisEventRecord Text kerAwsRegion :: Lens' KinesisEventRecord Region type KinesisEvent = RecordsEvent KinesisEventRecord instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.KinesisEvent.KinesisEventRecord instance GHC.Show.Show AWSLambda.Events.KinesisEvent.KinesisEventRecord instance GHC.Classes.Eq AWSLambda.Events.KinesisEvent.KinesisEventRecord instance GHC.Show.Show AWSLambda.Events.KinesisEvent.KinesisRecord instance GHC.Classes.Eq AWSLambda.Events.KinesisEvent.KinesisRecord instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.KinesisEvent.KinesisRecord -- | Entry point for AWS Lambda handlers deployed with -- serverless-haskell plugin. module AWSLambda.Handler -- | Process incoming events from serverless-haskell using a -- provided function. -- -- The handler receives the input event given to the AWS Lambda function, -- and its return value is returned from the function. -- -- This is intended to be used as main, for example: -- --
-- import qualified Data.Aeson as Aeson -- -- import AWSLambda -- -- main = lambdaMain handler -- -- handler :: Aeson.Value -> IO [Int] -- handler evt = do -- putStrLn "This should go to logs" -- print evt -- pure [1, 2, 3] ---- -- The handler function can receive arbitrary JSON values from custom -- invocations, or one of the events from the AWSLambda.Events -- module, such as S3Event: -- --
-- import AWSLambda.Events.S3Event -- -- handler :: S3Event -> IO () -- handler evt = do -- print $ records evt ---- -- If the Lambda function needs to process several types of events, use -- Alternative to combine several handlers: -- --
-- import AWSLambda -- import AWSLambda.Events.S3Event -- import Data.Aeson -- import Data.Aeson.Alternative -- -- main = lambdaMain $ handlerS3 `alternative` handlerCustom -- -- handlerS3 :: S3Event -> IO () -- handlerS3 = _ -- -- handlerCustom :: Value -> IO () -- handlerCustom = _ ---- -- When run outside the AWS Lambda environment, the input is read as JSON -- from the command line, and the result of the execution is printed, -- also as JSON, to the standard output. lambdaMain :: (FromJSON event, ToJSON res) => (event -> IO res) -> IO () module AWSLambda.Orphans instance Data.Aeson.Types.FromJSON.FromJSON Network.AWS.S3.Internal.ObjectKey instance Data.Aeson.Types.FromJSON.FromJSON Network.AWS.S3.Internal.ObjectVersionId instance Data.Aeson.Types.FromJSON.FromJSON Network.AWS.S3.Internal.ETag instance Data.Aeson.Types.FromJSON.FromJSON Network.AWS.S3.Types.Sum.Event -- | Based on -- https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.S3Events module AWSLambda.Events.S3Event newtype UserIdentityEntity UserIdentityEntity :: Text -> UserIdentityEntity [_uiePrincipalId] :: UserIdentityEntity -> Text uiePrincipalId :: Iso' UserIdentityEntity Text data S3BucketEntity S3BucketEntity :: !Text -> !BucketName -> !UserIdentityEntity -> S3BucketEntity [_sbeArn] :: S3BucketEntity -> !Text [_sbeName] :: S3BucketEntity -> !BucketName [_sbeOwnerIdentity] :: S3BucketEntity -> !UserIdentityEntity sbeOwnerIdentity :: Lens' S3BucketEntity UserIdentityEntity sbeName :: Lens' S3BucketEntity BucketName sbeArn :: Lens' S3BucketEntity Text data S3ObjectEntity S3ObjectEntity :: !Maybe ETag -> !ObjectKey -> !Maybe Integer -> !Text -> !Maybe ObjectVersionId -> S3ObjectEntity [_soeETag] :: S3ObjectEntity -> !Maybe ETag [_soeKey] :: S3ObjectEntity -> !ObjectKey [_soeSize] :: S3ObjectEntity -> !Maybe Integer [_soeSequencer] :: S3ObjectEntity -> !Text [_soeVersionId] :: S3ObjectEntity -> !Maybe ObjectVersionId soeVersionId :: Lens' S3ObjectEntity (Maybe ObjectVersionId) soeSize :: Lens' S3ObjectEntity (Maybe Integer) soeSequencer :: Lens' S3ObjectEntity Text soeKey :: Lens' S3ObjectEntity ObjectKey soeETag :: Lens' S3ObjectEntity (Maybe ETag) newtype RequestParametersEntity RequestParametersEntity :: Text -> RequestParametersEntity [_rpeSourceIPAddress] :: RequestParametersEntity -> Text rpeSourceIPAddress :: Iso' RequestParametersEntity Text data ResponseElementsEntity ResponseElementsEntity :: !Text -> !Text -> ResponseElementsEntity [_reeXAmzId2] :: ResponseElementsEntity -> !Text [_reeXAmzRequestId] :: ResponseElementsEntity -> !Text reeXAmzRequestId :: Lens' ResponseElementsEntity Text reeXAmzId2 :: Lens' ResponseElementsEntity Text data S3Entity S3Entity :: !S3BucketEntity -> !Text -> !S3ObjectEntity -> !Text -> S3Entity [_seBucket] :: S3Entity -> !S3BucketEntity [_seConfigurationId] :: S3Entity -> !Text [_seObject] :: S3Entity -> !S3ObjectEntity [_seS3SchemaVersion] :: S3Entity -> !Text seS3SchemaVersion :: Lens' S3Entity Text seObject :: Lens' S3Entity S3ObjectEntity seConfigurationId :: Lens' S3Entity Text seBucket :: Lens' S3Entity S3BucketEntity data S3EventNotification S3EventNotification :: !Region -> !Event -> !Text -> !UTCTime -> !Text -> !RequestParametersEntity -> !ResponseElementsEntity -> !S3Entity -> !UserIdentityEntity -> S3EventNotification [_senAwsRegion] :: S3EventNotification -> !Region [_senEventName] :: S3EventNotification -> !Event [_senEventSource] :: S3EventNotification -> !Text [_senEventTime] :: S3EventNotification -> !UTCTime [_senEventVersion] :: S3EventNotification -> !Text [_senRequestParameters] :: S3EventNotification -> !RequestParametersEntity [_senResponseElements] :: S3EventNotification -> !ResponseElementsEntity [_senS3] :: S3EventNotification -> !S3Entity [_senUserIdentity] :: S3EventNotification -> !UserIdentityEntity senUserIdentity :: Lens' S3EventNotification UserIdentityEntity senS3 :: Lens' S3EventNotification S3Entity senResponseElements :: Lens' S3EventNotification ResponseElementsEntity senRequestParameters :: Lens' S3EventNotification RequestParametersEntity senEventVersion :: Lens' S3EventNotification Text senEventTime :: Lens' S3EventNotification UTCTime senEventSource :: Lens' S3EventNotification Text senEventName :: Lens' S3EventNotification Event senAwsRegion :: Lens' S3EventNotification Region type S3Event = RecordsEvent S3EventNotification instance GHC.Show.Show AWSLambda.Events.S3Event.S3EventNotification instance GHC.Classes.Eq AWSLambda.Events.S3Event.S3EventNotification instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.S3Event.S3EventNotification instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.S3Event.S3Entity instance GHC.Show.Show AWSLambda.Events.S3Event.S3Entity instance GHC.Classes.Eq AWSLambda.Events.S3Event.S3Entity instance GHC.Show.Show AWSLambda.Events.S3Event.ResponseElementsEntity instance GHC.Classes.Eq AWSLambda.Events.S3Event.ResponseElementsEntity instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.S3Event.ResponseElementsEntity instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.S3Event.RequestParametersEntity instance GHC.Show.Show AWSLambda.Events.S3Event.RequestParametersEntity instance GHC.Classes.Eq AWSLambda.Events.S3Event.RequestParametersEntity instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.S3Event.S3ObjectEntity instance GHC.Show.Show AWSLambda.Events.S3Event.S3ObjectEntity instance GHC.Classes.Eq AWSLambda.Events.S3Event.S3ObjectEntity instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.S3Event.S3BucketEntity instance GHC.Show.Show AWSLambda.Events.S3Event.S3BucketEntity instance GHC.Classes.Eq AWSLambda.Events.S3Event.S3BucketEntity instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.S3Event.UserIdentityEntity instance GHC.Show.Show AWSLambda.Events.S3Event.UserIdentityEntity instance GHC.Classes.Eq AWSLambda.Events.S3Event.UserIdentityEntity -- | Utilities for decoding JSON into one of the possible types and -- handling the resulting sum type. module Data.Aeson.Alternative -- | One of the two values that has been parsed from JSON data AlternativeJSON a b -- | Handle either of the two types that have been parsed from JSON alternative :: (a -> r) -> (b -> r) -> AlternativeJSON a b -> r instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Data.Aeson.Alternative.AlternativeJSON a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Data.Aeson.Alternative.AlternativeJSON a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Data.Aeson.Alternative.AlternativeJSON a b) instance (Data.Aeson.Types.FromJSON.FromJSON a, Data.Aeson.Types.FromJSON.FromJSON b) => Data.Aeson.Types.FromJSON.FromJSON (Data.Aeson.Alternative.AlternativeJSON a b) module Data.Aeson.Embedded -- | Type for a JSON value embedded within a JSON string value newtype Embedded a Embedded :: a -> Embedded a [_unEmbed] :: Embedded a -> a unEmbed :: forall a_aDQC a_aDY0. Iso (Embedded a_aDQC) (Embedded a_aDY0) a_aDQC a_aDY0 instance GHC.Show.Show a => GHC.Show.Show (Data.Aeson.Embedded.Embedded a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Aeson.Embedded.Embedded a) instance Data.Aeson.Types.FromJSON.FromJSON a => Network.AWS.Data.Text.FromText (Data.Aeson.Embedded.Embedded a) instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Data.Aeson.Embedded.Embedded a) instance Data.Aeson.Types.ToJSON.ToJSON a => Network.AWS.Data.Text.ToText (Data.Aeson.Embedded.Embedded a) instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Data.Aeson.Embedded.Embedded a) -- | Provides FromJSON and ToJSON instances for anything -- that has FromText and ToText instances, e.g. -- TextValue Text, (FromJSON a, ToJSON a) => TextValue -- (Embedded a), TextValue Base64 module Data.Aeson.TextValue newtype TextValue a TextValue :: a -> TextValue a [_unTextValue] :: TextValue a -> a unTextValue :: forall a_aEvD a_aEDW. Iso (TextValue a_aEvD) (TextValue a_aEDW) a_aEvD a_aEDW instance Data.String.IsString a => Data.String.IsString (Data.Aeson.TextValue.TextValue a) instance GHC.Show.Show a => GHC.Show.Show (Data.Aeson.TextValue.TextValue a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Aeson.TextValue.TextValue a) instance Network.AWS.Data.Text.FromText a => Data.Aeson.Types.FromJSON.FromJSON (Data.Aeson.TextValue.TextValue a) instance Network.AWS.Data.Text.ToText a => Data.Aeson.Types.ToJSON.ToJSON (Data.Aeson.TextValue.TextValue a) module AWSLambda.Events.SQSEvent data SQSMessage body SQSMessage :: !Text -> !Text -> !TextValue body -> !HashMap Text Text -> !HashMap Text MessageAttribute -> !Text -> !Text -> !Text -> !Region -> SQSMessage body [_sqsmMessageId] :: SQSMessage body -> !Text [_sqsmReceiptHandle] :: SQSMessage body -> !Text [_sqsmBody] :: SQSMessage body -> !TextValue body [_sqsmAttributes] :: SQSMessage body -> !HashMap Text Text [_sqsmMessageAttributes] :: SQSMessage body -> !HashMap Text MessageAttribute [_sqsmMd5OfBody] :: SQSMessage body -> !Text [_sqsmEventSource] :: SQSMessage body -> !Text [_sqsmEventSourceARN] :: SQSMessage body -> !Text [_sqsmAwsRegion] :: SQSMessage body -> !Region sqsmReceiptHandle :: forall body_aF6k. Lens' (SQSMessage body_aF6k) Text sqsmMessageId :: forall body_aF6k. Lens' (SQSMessage body_aF6k) Text sqsmMessageAttributes :: forall body_aF6k. Lens' (SQSMessage body_aF6k) (HashMap Text MessageAttribute) sqsmMd5OfBody :: forall body_aF6k. Lens' (SQSMessage body_aF6k) Text sqsmEventSourceARN :: forall body_aF6k. Lens' (SQSMessage body_aF6k) Text sqsmEventSource :: forall body_aF6k. Lens' (SQSMessage body_aF6k) Text sqsmBody :: forall body_aF6k body_aGs9. Lens (SQSMessage body_aF6k) (SQSMessage body_aGs9) (TextValue body_aF6k) (TextValue body_aGs9) sqsmAwsRegion :: forall body_aF6k. Lens' (SQSMessage body_aF6k) Region sqsmAttributes :: forall body_aF6k. Lens' (SQSMessage body_aF6k) (HashMap Text Text) type SQSEvent body = RecordsEvent (SQSMessage body) -- | A Traversal to get messages from an SQSEvent sqsMessages :: Traversal (SQSEvent message) (SQSEvent message') message message' -- | A Traversal to get embedded JSON values from an SQSEvent sqsEmbedded :: Traversal (SQSEvent (Embedded v)) (SQSEvent (Embedded v')) v v' sqsBinary :: Traversal' (SQSEvent Base64) ByteString instance GHC.Generics.Generic (AWSLambda.Events.SQSEvent.SQSMessage body) instance GHC.Classes.Eq body => GHC.Classes.Eq (AWSLambda.Events.SQSEvent.SQSMessage body) instance GHC.Show.Show body => GHC.Show.Show (AWSLambda.Events.SQSEvent.SQSMessage body) instance Network.AWS.Data.Text.FromText message => Data.Aeson.Types.FromJSON.FromJSON (AWSLambda.Events.SQSEvent.SQSMessage message) -- | Based on -- https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.SNSEvents module AWSLambda.Events.SNSEvent data SNSMessage message SNSMessage :: !TextValue message -> !HashMap Text MessageAttribute -> !Text -> !Text -> !Text -> !Text -> !Text -> !UTCTime -> !Text -> !Text -> !Text -> SNSMessage message [_smMessage] :: SNSMessage message -> !TextValue message [_smMessageAttributes] :: SNSMessage message -> !HashMap Text MessageAttribute [_smMessageId] :: SNSMessage message -> !Text [_smSignature] :: SNSMessage message -> !Text [_smSignatureVersion] :: SNSMessage message -> !Text [_smSigningCertUrl] :: SNSMessage message -> !Text [_smSubject] :: SNSMessage message -> !Text [_smTimestamp] :: SNSMessage message -> !UTCTime [_smTopicArn] :: SNSMessage message -> !Text [_smType] :: SNSMessage message -> !Text [_smUnsubscribeUrl] :: SNSMessage message -> !Text smUnsubscribeUrl :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smType :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smTopicArn :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smTimestamp :: forall message_aJmT. Lens' (SNSMessage message_aJmT) UTCTime smSubject :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smSigningCertUrl :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smSignatureVersion :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smSignature :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smMessageId :: forall message_aJmT. Lens' (SNSMessage message_aJmT) Text smMessageAttributes :: forall message_aJmT. Lens' (SNSMessage message_aJmT) (HashMap Text MessageAttribute) smMessage :: forall message_aJmT message_aJBr. Lens (SNSMessage message_aJmT) (SNSMessage message_aJBr) (TextValue message_aJmT) (TextValue message_aJBr) data SNSRecord message SNSRecord :: !Text -> !Text -> !Text -> !SNSMessage message -> SNSRecord message [_srEventVersion] :: SNSRecord message -> !Text [_srEventSubscriptionArn] :: SNSRecord message -> !Text [_srEventSource] :: SNSRecord message -> !Text [_srSns] :: SNSRecord message -> !SNSMessage message srSns :: forall message_aJE2 message_aJPw. Lens (SNSRecord message_aJE2) (SNSRecord message_aJPw) (SNSMessage message_aJE2) (SNSMessage message_aJPw) srEventVersion :: forall message_aJE2. Lens' (SNSRecord message_aJE2) Text srEventSubscriptionArn :: forall message_aJE2. Lens' (SNSRecord message_aJE2) Text srEventSource :: forall message_aJE2. Lens' (SNSRecord message_aJE2) Text -- | SNSEvent. The message type is parameterised. To treat it as a -- text value use SNSEvent Text. To extract an embedded event -- object use the Embedded type. E.g. SNSEvent (Embedded -- S3Event) will treat the message as an embedded S3Event. To -- extract embedded Base64 encoded binary use SNSEvent Base64 type SNSEvent message = RecordsEvent (SNSRecord message) -- | A Traversal to get messages from an SNSEvent messages :: Traversal (SNSEvent message) (SNSEvent message') message message' -- | A Traversal to get embedded JSON values from an SNSEvent embedded :: Traversal (SNSEvent (Embedded v)) (SNSEvent (Embedded v')) v v' binary :: Traversal' (SNSEvent Base64) ByteString instance GHC.Generics.Generic (AWSLambda.Events.SNSEvent.SNSRecord message) instance GHC.Show.Show message => GHC.Show.Show (AWSLambda.Events.SNSEvent.SNSRecord message) instance GHC.Classes.Eq message => GHC.Classes.Eq (AWSLambda.Events.SNSEvent.SNSRecord message) instance Network.AWS.Data.Text.FromText message => Data.Aeson.Types.FromJSON.FromJSON (AWSLambda.Events.SNSEvent.SNSRecord message) instance GHC.Generics.Generic (AWSLambda.Events.SNSEvent.SNSMessage message) instance GHC.Show.Show message => GHC.Show.Show (AWSLambda.Events.SNSEvent.SNSMessage message) instance GHC.Classes.Eq message => GHC.Classes.Eq (AWSLambda.Events.SNSEvent.SNSMessage message) instance Network.AWS.Data.Text.FromText message => Data.Aeson.Types.FromJSON.FromJSON (AWSLambda.Events.SNSEvent.SNSMessage message) module AWSLambda.Events -- | Not yet implemented data DynamoDBEvent -- | Not yet implemented data SESEvent -- | Not yet implemented data CognitoEvent -- | Not yet implemented data CloudFormationEvent -- | Not yet implemented data CloudWatchLogsEvent -- | Not yet implemented data CloudWatchEventsEvent -- | Not yet implemented data CodeCommitEvent -- | Not yet implemented data ConfigEvent -- | Not yet implemented data AlexaEvent -- | Not yet implemented data LexEvent -- | Not yet implemented data APIGatewayEvent -- | Not yet implemented data IoTButtonEvent -- | Not yet implemented data CloudFrontEvent -- | Not yet implemented data FirehoseEvent -- | Not yet implemented data InvokeEvent -- | Sum type for all possible Lambda events. Parameterised on the type of -- SNS Events to be handled. See SNSEvent for details. data LambdaEvent message S3 :: !S3Event -> LambdaEvent message DynamoDB :: !DynamoDBEvent -> LambdaEvent message KinesisStream :: !KinesisEvent -> LambdaEvent message SNS :: !SNSEvent message -> LambdaEvent message SQS :: !SQSEvent message -> LambdaEvent message SES :: !SESEvent -> LambdaEvent message Cognito :: !CognitoEvent -> LambdaEvent message CloudFormation :: !CloudFormationEvent -> LambdaEvent message CloudWatchLogs :: !CloudWatchLogsEvent -> LambdaEvent message CloudWatchEvents :: !CloudWatchEventsEvent -> LambdaEvent message CodeCommit :: !CodeCommitEvent -> LambdaEvent message Config :: !ConfigEvent -> LambdaEvent message Alexa :: !AlexaEvent -> LambdaEvent message Lex :: !LexEvent -> LambdaEvent message APIGateway :: !APIGatewayEvent -> LambdaEvent message IoTButton :: !IoTButtonEvent -> LambdaEvent message CloudFront :: !CloudFrontEvent -> LambdaEvent message Firehose :: !FirehoseEvent -> LambdaEvent message Invoke :: !InvokeEvent -> LambdaEvent message Custom :: !Value -> LambdaEvent message _Custom :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) Value _Invoke :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) InvokeEvent _Firehose :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) FirehoseEvent _CloudFront :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) CloudFrontEvent _IoTButton :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) IoTButtonEvent _APIGateway :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) APIGatewayEvent _Lex :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) LexEvent _Alexa :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) AlexaEvent _Config :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) ConfigEvent _CodeCommit :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) CodeCommitEvent _CloudWatchEvents :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) CloudWatchEventsEvent _CloudWatchLogs :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) CloudWatchLogsEvent _CloudFormation :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) CloudFormationEvent _Cognito :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) CognitoEvent _SES :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) SESEvent _SQS :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) (SQSEvent message_aQqD) _SNS :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) (SNSEvent message_aQqD) _KinesisStream :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) KinesisEvent _DynamoDB :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) DynamoDBEvent _S3 :: forall message_aQqD. Prism' (LambdaEvent message_aQqD) S3Event instance Network.AWS.Data.Text.FromText message => Data.Aeson.Types.FromJSON.FromJSON (AWSLambda.Events.LambdaEvent message) -- | Tools for running Haskell on AWS Lambda using Serverless. -- --
npm init . npm install --save serverless -- serverless-haskell@x.y.zThe version of the NPM package to -- install must match the version of the Haskell package.
service: myservice provider: name: aws runtime: haskell -- functions: myfunc: handler: mypackage.mypackage-exe # Here, mypackage -- is the Haskell package name and mypackage-exe is the # executable name -- as defined in the Cabal file plugins: - serverless-haskell
custom: haskell: stackBuildArgs: - -- --pedantic - --allow-different-user
custom: haskell: -- arguments: myfunc: - --arg1 - --arg2 - arg3
custom: haskell: docker: -- false
custom: haskell: buildAll: -- false
-- import qualified Data.Aeson as Aeson -- -- import AWSLambda -- -- main = lambdaMain handler -- -- handler :: Aeson.Value -> IO [Int] -- handler evt = do -- putStrLn "This should go to logs" -- print evt -- pure [1, 2, 3] ---- -- The handler function can receive arbitrary JSON values from custom -- invocations, or one of the events from the AWSLambda.Events -- module, such as S3Event: -- --
-- import AWSLambda.Events.S3Event -- -- handler :: S3Event -> IO () -- handler evt = do -- print $ records evt ---- -- If the Lambda function needs to process several types of events, use -- Alternative to combine several handlers: -- --
-- import AWSLambda -- import AWSLambda.Events.S3Event -- import Data.Aeson -- import Data.Aeson.Alternative -- -- main = lambdaMain $ handlerS3 `alternative` handlerCustom -- -- handlerS3 :: S3Event -> IO () -- handlerS3 = _ -- -- handlerCustom :: Value -> IO () -- handlerCustom = _ ---- -- When run outside the AWS Lambda environment, the input is read as JSON -- from the command line, and the result of the execution is printed, -- also as JSON, to the standard output. lambdaMain :: (FromJSON event, ToJSON res) => (event -> IO res) -> IO () -- | Based on -- https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.APIGatewayEvents -- -- To enable processing of API Gateway events, use the events -- key in serverless.yml as usual: -- --
-- functions:
-- myapifunc:
-- handler: mypackage.mypackage-exe
-- events:
-- - http:
-- path: hello/{name}
-- method: get
--
--
-- Then use apiGatewayMain in the handler to process the requests.
module AWSLambda.Events.APIGateway
type Method = Text
type HeaderName = Text
type HeaderValue = Text
type QueryParamName = Text
type QueryParamValue = Text
type PathParamName = Text
type PathParamValue = Text
type StageVarName = Text
type StageVarValue = Text
data RequestIdentity
RequestIdentity :: !Maybe Text -> !Maybe Text -> !Maybe Text -> !Maybe Text -> !Maybe Text -> !Maybe IP -> !Maybe Text -> !Maybe Text -> !Maybe Text -> !Maybe Text -> !Maybe Text -> RequestIdentity
[_riCognitoIdentityPoolId] :: RequestIdentity -> !Maybe Text
[_riAccountId] :: RequestIdentity -> !Maybe Text
[_riCognitoIdentityId] :: RequestIdentity -> !Maybe Text
[_riCaller] :: RequestIdentity -> !Maybe Text
[_riApiKey] :: RequestIdentity -> !Maybe Text
[_riSourceIp] :: RequestIdentity -> !Maybe IP
[_riCognitoAuthenticationType] :: RequestIdentity -> !Maybe Text
[_riCognitoAuthenticationProvider] :: RequestIdentity -> !Maybe Text
[_riUserArn] :: RequestIdentity -> !Maybe Text
[_riUserAgent] :: RequestIdentity -> !Maybe Text
[_riUser] :: RequestIdentity -> !Maybe Text
readParse :: Read a => String -> Text -> Parser a
riUserArn :: Lens' RequestIdentity (Maybe Text)
riUserAgent :: Lens' RequestIdentity (Maybe Text)
riUser :: Lens' RequestIdentity (Maybe Text)
riSourceIp :: Lens' RequestIdentity (Maybe IP)
riCognitoIdentityPoolId :: Lens' RequestIdentity (Maybe Text)
riCognitoIdentityId :: Lens' RequestIdentity (Maybe Text)
riCognitoAuthenticationType :: Lens' RequestIdentity (Maybe Text)
riCognitoAuthenticationProvider :: Lens' RequestIdentity (Maybe Text)
riCaller :: Lens' RequestIdentity (Maybe Text)
riApiKey :: Lens' RequestIdentity (Maybe Text)
riAccountId :: Lens' RequestIdentity (Maybe Text)
data Authorizer
Authorizer :: !Maybe Text -> !Object -> !Object -> Authorizer
[_aPrincipalId] :: Authorizer -> !Maybe Text
[_aClaims] :: Authorizer -> !Object
[_aContext] :: Authorizer -> !Object
aPrincipalId :: Lens' Authorizer (Maybe Text)
aContext :: Lens' Authorizer Object
aClaims :: Lens' Authorizer Object
data ProxyRequestContext
ProxyRequestContext :: !Maybe Text -> !Text -> !Text -> !Text -> !Text -> !RequestIdentity -> !Text -> !Text -> !Text -> !Text -> !Maybe Authorizer -> ProxyRequestContext
[_prcPath] :: ProxyRequestContext -> !Maybe Text
[_prcAccountId] :: ProxyRequestContext -> !Text
[_prcResourceId] :: ProxyRequestContext -> !Text
[_prcStage] :: ProxyRequestContext -> !Text
[_prcRequestId] :: ProxyRequestContext -> !Text
[_prcIdentity] :: ProxyRequestContext -> !RequestIdentity
[_prcResourcePath] :: ProxyRequestContext -> !Text
[_prcHttpMethod] :: ProxyRequestContext -> !Text
[_prcApiId] :: ProxyRequestContext -> !Text
[_prcProtocol] :: ProxyRequestContext -> !Text
[_prcAuthorizer] :: ProxyRequestContext -> !Maybe Authorizer
prcStage :: Lens' ProxyRequestContext Text
prcResourcePath :: Lens' ProxyRequestContext Text
prcResourceId :: Lens' ProxyRequestContext Text
prcRequestId :: Lens' ProxyRequestContext Text
prcProtocol :: Lens' ProxyRequestContext Text
prcPath :: Lens' ProxyRequestContext (Maybe Text)
prcIdentity :: Lens' ProxyRequestContext RequestIdentity
prcHttpMethod :: Lens' ProxyRequestContext Text
prcAuthorizer :: Lens' ProxyRequestContext (Maybe Authorizer)
prcApiId :: Lens' ProxyRequestContext Text
prcAccountId :: Lens' ProxyRequestContext Text
data APIGatewayProxyRequest body
APIGatewayProxyRequest :: !Text -> !ByteString -> !Method -> !RequestHeaders -> !Query -> !HashMap PathParamName PathParamValue -> !HashMap StageVarName StageVarValue -> !ProxyRequestContext -> !Maybe (TextValue body) -> APIGatewayProxyRequest body
[_agprqResource] :: APIGatewayProxyRequest body -> !Text
[_agprqPath] :: APIGatewayProxyRequest body -> !ByteString
[_agprqHttpMethod] :: APIGatewayProxyRequest body -> !Method
[_agprqHeaders] :: APIGatewayProxyRequest body -> !RequestHeaders
[_agprqQueryStringParameters] :: APIGatewayProxyRequest body -> !Query
[_agprqPathParameters] :: APIGatewayProxyRequest body -> !HashMap PathParamName PathParamValue
[_agprqStageVariables] :: APIGatewayProxyRequest body -> !HashMap StageVarName StageVarValue
[_agprqRequestContext] :: APIGatewayProxyRequest body -> !ProxyRequestContext
[_agprqBody] :: APIGatewayProxyRequest body -> !Maybe (TextValue body)
agprqStageVariables :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) (HashMap StageVarName StageVarValue)
agprqResource :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) Text
agprqRequestContext :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) ProxyRequestContext
agprqQueryStringParameters :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) Query
agprqPathParameters :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) (HashMap PathParamName PathParamValue)
agprqPath :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) ByteString
agprqHttpMethod :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) Method
agprqHeaders :: forall body_aTFU. Lens' (APIGatewayProxyRequest body_aTFU) RequestHeaders
agprqBody :: forall body_aTFU body_aU28. Lens (APIGatewayProxyRequest body_aTFU) (APIGatewayProxyRequest body_aU28) (Maybe (TextValue body_aTFU)) (Maybe (TextValue body_aU28))
-- | Get the request body, if there is one
requestBody :: Getter (APIGatewayProxyRequest body) (Maybe body)
-- | Get the embedded request body, if there is one
requestBodyEmbedded :: Getter (APIGatewayProxyRequest (Embedded v)) (Maybe v)
-- | Get the binary (decoded Base64) request body, if there is one
requestBodyBinary :: Getter (APIGatewayProxyRequest Base64) (Maybe ByteString)
data APIGatewayProxyResponse body
APIGatewayProxyResponse :: !Int -> !ResponseHeaders -> !Maybe (TextValue body) -> APIGatewayProxyResponse body
[_agprsStatusCode] :: APIGatewayProxyResponse body -> !Int
[_agprsHeaders] :: APIGatewayProxyResponse body -> !ResponseHeaders
[_agprsBody] :: APIGatewayProxyResponse body -> !Maybe (TextValue body)
agprsStatusCode :: forall body_aU41. Lens' (APIGatewayProxyResponse body_aU41) Int
agprsHeaders :: forall body_aU41. Lens' (APIGatewayProxyResponse body_aU41) ResponseHeaders
agprsBody :: forall body_aU41 body_aUlc. Lens (APIGatewayProxyResponse body_aU41) (APIGatewayProxyResponse body_aUlc) (Maybe (TextValue body_aU41)) (Maybe (TextValue body_aUlc))
response :: Int -> APIGatewayProxyResponse body
responseOK :: APIGatewayProxyResponse body
responseNotFound :: APIGatewayProxyResponse body
responseBadRequest :: APIGatewayProxyResponse body
responseBody :: Setter' (APIGatewayProxyResponse body) (Maybe body)
responseBodyEmbedded :: Setter' (APIGatewayProxyResponse (Embedded body)) (Maybe body)
responseBodyBinary :: Setter' (APIGatewayProxyResponse Base64) (Maybe ByteString)
-- | Process incoming events from serverless-haskell using a
-- provided function.
--
-- This is a specialisation of lambdaMain for API Gateway.
--
-- The handler receives the input event given to the AWS Lambda function,
-- and its return value is returned from the function.
--
-- This is intended to be used as main, for example:
--
-- -- import AWSLambda.Events.APIGateway -- import Control.Lens -- import Data.Aeson -- import Data.Aeson.Embedded -- -- main = apiGatewayMain handler -- -- handler :: APIGatewayProxyRequest (Embedded Value) -> IO (APIGatewayProxyResponse (Embedded [Int])) -- handler request = do -- putStrLn "This should go to logs" -- print $ request ^. requestBody -- pure $ responseOK & responseBodyEmbedded ?~ [1, 2, 3] ---- -- The type parameters reqBody and resBody represent -- the types of request and response body, respectively. The -- FromText and ToText contraints are required because -- these values come from string fields in the request and response JSON -- objects. To get direct access to the body string, use Text as -- the parameter type. To treat the body as a stringified embedded JSON -- value, use Embedded a, where a has the appropriate -- FromJSON or ToJSON instances. To treat the body as -- base 64 encoded binary use Base64. apiGatewayMain :: (FromText reqBody, ToText resBody) => (APIGatewayProxyRequest reqBody -> IO (APIGatewayProxyResponse resBody)) -> IO () instance GHC.Generics.Generic (AWSLambda.Events.APIGateway.APIGatewayProxyResponse body) instance GHC.Show.Show body => GHC.Show.Show (AWSLambda.Events.APIGateway.APIGatewayProxyResponse body) instance GHC.Classes.Eq body => GHC.Classes.Eq (AWSLambda.Events.APIGateway.APIGatewayProxyResponse body) instance Network.AWS.Data.Text.ToText body => Data.Aeson.Types.ToJSON.ToJSON (AWSLambda.Events.APIGateway.APIGatewayProxyResponse body) instance Network.AWS.Data.Text.FromText body => Data.Aeson.Types.FromJSON.FromJSON (AWSLambda.Events.APIGateway.APIGatewayProxyResponse body) instance GHC.Generics.Generic (AWSLambda.Events.APIGateway.APIGatewayProxyRequest body) instance GHC.Show.Show body => GHC.Show.Show (AWSLambda.Events.APIGateway.APIGatewayProxyRequest body) instance GHC.Classes.Eq body => GHC.Classes.Eq (AWSLambda.Events.APIGateway.APIGatewayProxyRequest body) instance Network.AWS.Data.Text.FromText body => Data.Aeson.Types.FromJSON.FromJSON (AWSLambda.Events.APIGateway.APIGatewayProxyRequest body) instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.APIGateway.ProxyRequestContext instance GHC.Show.Show AWSLambda.Events.APIGateway.ProxyRequestContext instance GHC.Classes.Eq AWSLambda.Events.APIGateway.ProxyRequestContext instance GHC.Show.Show AWSLambda.Events.APIGateway.Authorizer instance GHC.Classes.Eq AWSLambda.Events.APIGateway.Authorizer instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.APIGateway.Authorizer instance GHC.Show.Show AWSLambda.Events.APIGateway.RequestIdentity instance GHC.Classes.Eq AWSLambda.Events.APIGateway.RequestIdentity instance Data.Aeson.Types.FromJSON.FromJSON AWSLambda.Events.APIGateway.RequestIdentity