Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utility to package lambda
Example usage, you need to run it on AWS Linux
(e.g. Docker, see Dockerfile)
with GHC
, cabal
and cabal-plan
available.
module Main (main) where import AWS.Lambda.RuntimeAPI.Package (defaultConf
,packageAwsLambda
) import Data.Char (isSpace) import qualified Data.ByteString.Lazy as LBS import qualified System.Process as P main :: IO () main = do -- Build the executable let exe = "example-lambda" P.callProcess "cabal" ["new-build", exe] -- Find the build artifact exePath <- trim <$> P.readProcess "cabal-plan" [ "list-bin", exe ] "" putStrLn $ "Packaging executable: " ++ exePath -- Package it zipFile <-packageAwsLambda
defaultConf
exePath LBS.writeFile "example-lambda.zip" zipFile where trim = dropWhile isSpace . reverse . dropWhile isSpace . reverse
Given such environment, we can build an example lambda function:
% docker run -ti --rm -v $(pwd):work -w work amazonlinux-with-ghc % cabal new-update % cabal new-build % runghc package-example-lambda.hs
The resulting example-lambda.zip
is ready to be uploaded!
Synopsis
- packageAwsLambda :: Conf -> FilePath -> IO ByteString
- data Conf = Conf {
- _confAdditionalLibs :: ![String]
- _confReadFile :: !(FilePath -> IO ByteString)
- defaultConf :: Conf
- confAdditionalLibs :: Functor f => ([String] -> f [String]) -> Conf -> f Conf
- confReadFile :: Functor f => ((FilePath -> IO ByteString) -> f (FilePath -> IO ByteString)) -> Conf -> f Conf
- findExtraLibs :: [String] -> FilePath -> IO [FilePath]
Documentation
:: Conf | |
-> FilePath | |
-> IO ByteString | Result is ZIP package |
Package AWS Lambda executable.
Conf | |
|
defaultConf :: Conf Source #
confReadFile :: Functor f => ((FilePath -> IO ByteString) -> f (FilePath -> IO ByteString)) -> Conf -> f Conf Source #