Slide 1

Slide 1 text

DEMO build crud app with serverless elixir おーはら@tokyo.ex

Slide 2

Slide 2 text

agenda ● about me ● how to run ● demo ● まとめ

Slide 3

Slide 3 text

about me ● Tsunenori Ohara/おーはら ○ Twitter: @ohrdev ○ Github: ohr486

Slide 4

Slide 4 text

how to run repo: https://github.com/ohr486/serverless_elixir_demo 利用ライブラリ: - erllambda - mix_erllambda 以下のようなアプリを作成します - CR(U)D操作のできるAPI - 環境はAWS、Lambda、ApiGatewayを利用 - DBはDynamoDBを利用

Slide 5

Slide 5 text

step0 ● release buildの為のdocker imageのbuild ○ https://github.com/alertlogic/erllambda_docker ● build ○ mix deps.get ○ docker run -it --rm -v `pwd`:/buildroot -w /buildroot -e MIX_ENV=prod erllambda:21-elixir mix erllambda.rellease

Slide 6

Slide 6 text

step1 ● cloudformationの為のS3 bucketを作成

Slide 7

Slide 7 text

step2 ● パッケージング ○ aws cloudformation package --template-file etc/template.yaml --output-template-file packaged.yaml --s3-bucket japanex-demo

Slide 8

Slide 8 text

step3 ● deploy ○ aws cloudformation deploy --capabilities CAPABILITY_IAM --template-file packaged.yaml --stack-name japanex-demo

Slide 9

Slide 9 text

step4 ● deployスタックを確認 ○ aws cloudformation describe-stacks --stack-name japanex-demo --query 'Stacks[].Outputs' ○ 作成したendpointを確認 ● API ENDPOINTの設定 ○ export APIENDP=xxxxxxx

Slide 10

Slide 10 text

step5 ● アイテムの作成 (CRUD) ○ curl -X POST "$APIENDP?id=foo2&bar=quz2"

Slide 11

Slide 11 text

step6 ● アイテムリスト取得 ○ curl $APIENDP

Slide 12

Slide 12 text

step7 ● アイテム削除 ○ curl -X DELETE "$APIENDP?id=foo2"

Slide 13

Slide 13 text

step8 ● アプリ削除 ○ aws cloudformation delete-stack --stack-name japanex-demo

Slide 14

Slide 14 text

まとめ ● 簡単なCR(U)Dアプリをserverlessで作成するデモを行いました ● デモの通り、まだまだオペレーションが煩雑です ○ このあたりをいい具合にラップしてくれるツール /FW等は現状まだありません ○ oss貢献のチャンス!