Skip to content

Commit 41564a6

Browse files
committed
A bit more docs.
1 parent 8f0698f commit 41564a6

File tree

1 file changed

+13
-66
lines changed

1 file changed

+13
-66
lines changed

doc/06-deploying-a-lambda.md

Lines changed: 13 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,23 @@
22
title: Deploying a Lambda
33
---
44

5-
# Deploying a Lambda
5+
## Using the template Makefile
66

77
To deploy your project to AWS Lambda, we have provided a `Makefile` to make your life easier.
8-
Run `make` from the root of your project, and you will have a `build/function.zip` generated for you.
98

10-
Note that this uses [**Docker**](https://www.docker.com) underneath, so make sure you have it installed
11-
and set-up on your system.
9+
Run `make` from the root of your project, and you will have a [**Docker**](https://www.docker.com) image generated for you that is ready to be deployed onto AWS Lambda.
1210

13-
## Manual deploy
11+
## Building the executable manually
1412

15-
To build the `function.zip` file manually, you need to run these commands:
13+
You could also build the executable manually, but that is troublesome because it either needs to be static or you need to make sure to ship all library dependencies as well as build it on the same environment it's going to run on.
1614

17-
```bash
18-
# Create the output `build` directory
19-
mkdir -p build
20-
# Perform a clean build of the project using docker
21-
# (In some cases `stack clean` is not needed, you can try removing it)
22-
stack clean --docker
23-
stack build --docker
15+
For simple executables without dependencies, you could just add the following to your `package.yaml`, build the `bootstrap` and ship it to AWS using a `.zip` file.
2416

25-
# Copy the generated executable to the output path
26-
cp $(stack --docker path --local-install-root)/bin/bootstrap build
27-
28-
# Create a `function.zip` file to upload
29-
cd build && zip function.zip bootstrap && rm bootstrap && cd ..
30-
```
31-
32-
## AWS Lambda Console
33-
34-
In the AWS Lambda console select `Create function` and give your function a name,
35-
e.g. `myHaskellLambda`, and for the runtime select `'Provide your own bootstrap'`.
36-
37-
![creating a lambda screenshot](https://imgur.com/Q8vT9ow.png)
38-
39-
![filling aws lambda information](https://imgur.com/OaUL8aA.png)
40-
41-
Inside your function configuration, select `'Upload a .zip file'` for code entry type.
42-
Select the `function.zip` in the Function package. Change the Handler
43-
to `src/Lib.handler`.
44-
45-
Remember to select `Save` to save your configuration.
46-
47-
![uploading handler](https://imgur.com/fdCmjGS.png)
48-
49-
50-
Next to the Test button select `'Configure test events'` and use the following JSON for
51-
a successful test.
52-
53-
![configuring test events location](https://imgur.com/mYLA3xX.png)
54-
![configuring test events window](https://imgur.com/gpvKMSD.png)
55-
56-
```
57-
{
58-
"personName": "Bobby",
59-
"personAge": 21
60-
}
61-
```
62-
63-
For a test which captures the error and results in a failure use the following JSON.
64-
65-
```
66-
{
67-
"personName": "Bobby",
68-
"personAge": -1
69-
}
70-
```
71-
After selecting the test you wish to run and pressing `Test` you will see the resul in the `Execution result` area. For successful execution the returned data will be the same as the input.
72-
73-
In the failure case the returned data will be `'A person's age must be positive'`.
74-
75-
![failed execution](https://imgur.com/P4J1AQc.png)
76-
77-
Congratulations you have ran your first AWS Lambda using the Haskell runtime!
17+
```yaml
18+
ghc-options:
19+
.. other options
20+
- -O2
21+
- -static
22+
cc-options: -static
23+
ld-options: -static -pthread
24+
```

0 commit comments

Comments
 (0)