Skip to content

Commit

Permalink
Build in a docker image and add a template.yaml for sam local testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
IamfromSpace committed Dec 5, 2018
1 parent 7b11fb8 commit 9e9e0d8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -115,6 +115,9 @@ cabal.project.local~
# CMake
cmake-build-*/

# Nix
result/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

Expand Down
21 changes: 21 additions & 0 deletions README.md
@@ -1 +1,22 @@
# aws-lambda-runtime

## Local Testing

### Dependencies

- stack
- docker
- aws-sam-cli (>v0.8.0)

### Build

```bash
stack build
cp .stack-work/install/x86_64-linux-${docker_image_hash}/lts-12.21/8.4.4/bin/aws-lambda-runtime result/bootstrap
```

### Execute

```bash
echo '{ "value": 7 }' | sam local invoke --region us-east-1
```
3 changes: 3 additions & 0 deletions package.yaml
Expand Up @@ -8,6 +8,9 @@ category: Web,AWS
extra-source-files:
- README.md

docker:
enable: true

dependencies:
- base >= 4.7 && < 5
- req
Expand Down
3 changes: 2 additions & 1 deletion src/Main.hs
@@ -1,5 +1,6 @@
module Main where

import Control.Monad (forever)
import Control.Monad.IO.Class
import Data.Aeson
import Data.ByteString.Char8 hiding (putStrLn)
Expand All @@ -18,7 +19,7 @@ instance ToJSON HardCodedEvent
instance FromJSON HardCodedEvent

main :: IO ()
main = runReq def $ do
main = forever $ runReq def $ do
-- Retreive settings
awsLambdaRuntimeApi <- liftIO $ getEnv "AWS_LAMBDA_RUNTIME_API"
-- TODO: Is baseOptions an appropriate way to get/pass the port?
Expand Down
13 changes: 13 additions & 0 deletions template.yaml
@@ -0,0 +1,13 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: Test for the Haskell Runtime.
Resources:
helloworld:
Type: 'AWS::Serverless::Function'
Properties:
Handler: NOT_USED
Runtime: provided
CodeUri: result
Description: Test for the Haskell Runtime.
MemorySize: 128
Timeout: 3

0 comments on commit 9e9e0d8

Please sign in to comment.