Haskell AWS Lambda Runtime outside US-East-1

A quick a rough howto for getting the amazing Haskell AWS Lambda Runtime from The Agile Monkeys running in other regions. The runtime as described currently only works in US-East-1. You may want to run it in Canada, or Ireland perhaps. Read on.

UPDATE: The Agile Monkeys have their AWS Lambda Layer shared in all regions now as arn:aws:lambda:<YOUR REGION>:785355572843:layer:haskell-runtime:2 and have updated their article accordingly.

Read on if you are interesting in building the layer yourself or modifying it.

This guide assumes you have already followed Nikita Tchayka's excellent guide and have this working in US-East-1. If you haven't, please do that first.

What I'll describe now is how to expand Nikita's solution to work in other AWS Regions.

Note: this is essentially a transcription of the project's CircleCI build. My novel contribution is enabling docker so it will build a usable bootstrap even on macOS or Windows.

First, you'll need the aws-lambda-haskell-runtime code:

git clone git@github.com:theam/aws-lambda-haskell-runtime.git

Then you'll need to modify the configuration to use Docker for the build step:

cd aws-lambda-haskell-runtime
echo 'docker:
  enable: true
' >> stack.yaml

Then you'll need to build the bootstrap as follows:

stack build
cd (dirname (stack path --local-install-root)/bin/bootstrap)
zip runtime.zip bootstrap

Then publish that ZIP as an AWS Lambda Layer (this :

aws lambda publish-layer-version \
--layer-name haskell-runtime \
--zip-file fileb://runtime.zip \
--region ca-central-1

Take note of the LayerVersionArn returned and use that instead of arn:aws:lambda:us-east-1:785355572843:layer:haskell-runtime:2 as supplied in Nikita's guide.

You should now have a working Haskell AWS Lambda Runtime in Canada - Central.