choonkeat / elm-webapp

A setup for writing http based, client-server app in elm, inspired wholly by lamdera.com
https://package.elm-lang.org/packages/choonkeat/elm-webapp/latest
MIT License
57 stars 7 forks source link

support AWS Lambda out of the box #3

Closed choonkeat closed 3 years ago

choonkeat commented 3 years ago

Until this is merged, it's available via npx elm-fullstack@next, for example

$ npx elm-fullstack@next element helloworld
npx: installed 1 in 3.446s
Initializing helloworld ...

now execute:

  1. cd helloworld
  2. make install
  3. make

Here's how I setup my API Gateway

Screenshot 2021-01-29 at 2 00 49 PM Screenshot 2021-01-29 at 2 00 53 PM Screenshot 2021-01-29 at 2 00 58 PM

The Lambda side looks weird, complaining about doesn’t include a route with path /*

Screenshot 2021-01-29 at 2 02 21 PM

But things work.. so 🤷

Screenshot 2021-01-29 at 2 03 34 PM

Remember to set environment variable LAMBDA=true for AWS Lambda, otherwise it won't work (with an error about index.handler not exported)

Screenshot 2021-01-29 at 2 04 39 PM

Optionally set env ASSETS_HOST to use your CDN, e.g. ASSETS_HOST=https://assets.example.com