Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AWS Serverless Express 入門
Search
Nokogiri
August 03, 2018
Technology
0
1.1k
AWS Serverless Express 入門
AWS Lambda を使って Express を 一瞬で公開する方法
Nokogiri
August 03, 2018
Tweet
Share
More Decks by Nokogiri
See All by Nokogiri
React Testing Libraryでの WAI-ARIAロールの活用事例
undefined_name
1
98
自動テストは何の役に立つのか そして役に立たないのか
undefined_name
5
1.6k
Pipe Operator (|>) の紹介
undefined_name
2
220
FizzBuzzで学ぶOCP
undefined_name
0
72
エンジニアとQAでコラボするフロントエンドリアーキテクチャ開発の事例
undefined_name
4
2.6k
オブジェクト指向のプラクティスをフロントエンドで活用する
undefined_name
7
1.4k
モププロ@kintone開発チーム
undefined_name
1
520
勉強会で登壇者に 質問しづらい課題を解決する サービスをリリースしました🎉
undefined_name
2
1.2k
Usefull GitLens
undefined_name
3
740
Other Decks in Technology
See All in Technology
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.6k
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
500
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
590
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
Lambdaと地方とコミュニティ
miu_crescent
2
370
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
470
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
170
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
150
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
170
Application Development WG Intro at AppDeveloperCon
salaboy
0
180
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
65
11k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
How GitHub (no longer) Works
holman
310
140k
4 Signs Your Business is Dying
shpigford
180
21k
Adopting Sorbet at Scale
ufuk
73
9.1k
Docker and Python
trallard
40
3.1k
Thoughts on Productivity
jonyablonski
67
4.3k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
The Pragmatic Product Professional
lauravandoore
31
6.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
Transcript
2018/08/03 ؔNodeֶԂ 3࣌ݶ AWS Serverless Eλpress ೖ AWS Lambda Λͬͯ
Express Λ ҰॠͰެ։͢Δํ๏
AWS Serverless Express ͬͯ·͔͢ʁ
JavaScript / Java / React / AWS / Vim ͡Ί·ͯ͠!
Taiki Nishi @nkgrnkgr Nokogiri Blog nkgrnkgr.github.io WebΞϓϦέʔγϣϯΤϯδχΞ ๏ਓ͚άϧʔϓΣΞαʔϏεͷ։ൃ HN: Nokogiri(nkgrnkgr) Ұࣇͷʢࠓ݄ೋࣇͷʹͳΓ·͢ ʣ Speaker Deck
Expressͬͨ͜ͱ͋Γ·͔͢ʁ
AWS Lambdaͬͨ͜ͱ͋Γ·͔͢ʁ
ExpressΛ͍ͬͯΔਓ͕ AWS LambdaΛͬͯ ͤʹͳΕΔͰ͢ ☺
What is Serverless ? ͦͦServerlessͱʁ 1
αʔόʔϨείϯϐϡʔςΟϯάͱɺΫϥυϓϩό Πμʔ͕ΞϓϦέʔγϣϯʹඞཁͳϚγϯϦιʔεͷׂ ΓͯΛಈతʹཧ͠ɺࣄલʹߪೖ͞Εͨ͜ͱʹجͮ͘ ٻͰͳ͘ɺ֤ΞϓϦέʔγϣϯཁٻΛຬͨͨ͢Ίʹ ༻͞ΕΔݸʑͷϦιʔεྔʹج͍ͮͨٻΛߦ͏Α͏ ͳΫϥυίϯϐϡʔςΟϯάϞσϧɻ “ Wikipedia ΑΓ
CLOUD FUNCTIONS AWS Lambda Azure functions ओͳ Serverless Platform
CLOUD FUNCTIONS AWS Lambda Azure functions ओͳ Serverless Platform Today’s
Topic
AWS Lambda ͷಛ ։ൃऀ͕࣮ߦڥͷαʔόʔΛ४උͤͣίʔυΛσϓϩΠ͢Δ͚ͩ HTTP ϦΫΤετͳͲ༷ʑͳΠϕϯτΛτϦΨʔʹؔΛ࣮ߦ͢Δ Φʔτεέʔϧ ॳճىಈʹ͕͔͔࣌ؒΔ σϓϩΠͰ͖ΔϑΝΠϧαΠζ͕ 50MB
·Ͱ 1ϦΫΤετ͋ͨΓͷ࠷େ࣮ߦ͕࣌ؒ 300ඵ ͍Ͳ͜ΖΛબͿ͕ͱʹ͔͍҆͘ 1ϲ݄ 100M ϦΫΤετ·Ͱແྉ Ҏ߱ 100M ϦΫΤετຖʹ 0.2 US$
What is AWS Serverless Express ? AWS Serverless Express ͱʁ
2
AWS Serverless Express AWS LambdaͱAPI Gatewayͷ্ʹɺExpress༻ͯ͠αʔόʔϨε ΞϓϦέʔγϣϯͱREST APIΛ࣮ߦ͢ΔAWSެࣜϥΠϒϥϦ ExpressͷMiddleware ʹՃ͢Δ͚ͩͰ
LambdaͰ࣮ߦՄೳʹͳΔ https://github.com/awslabs/aws-serverless-express
How to use 3
Express ʹ aws-serverless-express ΛΠϯετʔϧ STEP1 STEP2 STEP3 STEP4 ❯ npm
install aws-serverless-express +
[email protected]
updated 1 package and audited 198 packages in 2.889s found 2 low severity vulnerabilities run `npm audit fix` to fix them, or `npm audit` for details
const awsServerlessExpress = require('aws-serverless-express'); const app = require('./app'); const server
= awsServerlessExpress.createServer(app); exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context); Lambda ͔Βݺͼग़͞ΕΔ handler Λ࡞ STEP1 STEP2 STEP3 STEP4 index.js
ࠓ Express ͷ middleware ʹ ͜ͷϥΠϒϥϦΛՃ STEP1 STEP2 STEP3 STEP4
const serverlessExpress = require('aws-serverless-express/middleware'); var app = express(); app.use(serverlessExpress.eventContext()); app.js
ࠓ Express ͷ middleware ʹ ͜ͷϥΠϒϥϦΛՃ STEP1 STEP2 STEP3 STEP4
const serverlessExpress = require('aws-serverless-express/middleware'); var app = express(); app.use(serverlessExpress.eventContext()); app.js ΞϓϦέʔγϣϯͱͯ͠Δ͜ͱҎ্ͰऴΘΓ
Lambda ͷσϓϩΠ Serverless Flamework Λར༻ STEP1 STEP2 STEP3 STEP4 $
npm install serverless -g +
[email protected]
updated 3 packages in 11.062s https://serverless.com/framework/
σϓϩΠ༻ʹ ઃఆϑΝΠϧΛ࡞ STEP1 STEP2 STEP3 STEP4 service: serverless-express-example provider: name:
aws runtime: nodejs8.10 stage: dev region: ap-northeast-1 functions: app: handler: index.handler events: - http: ANY / - http: 'ANY {proxy+}' serverless.yml
❯ sls deploy Serverless: Packaging service... Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3... Serverless: Uploading artifacts... Serverless: Uploading service .zip file to S3 (2.16 MB)... Serverless: Validating template... Serverless: Updating Stack... Serverless: Checking Stack update progress... .............. Serverless: Stack update finished... Service Information service: serverless-express-example stage: dev region: ap-northeast-1 stack: serverless-express-example-dev api keys: None endpoints: ANY - https://u8klxp40gc.execute-api.ap-northeast-1.amazonaws.com/dev ANY - https://u8klxp40gc.execute-api.ap-northeast-1.amazonaws.com/dev/{proxy+} functions: app: serverless-express-example-dev-app APIGawayͷEndPointsͷ࡞͔ΒίʔυͷσϓϩΠ·Ͱશ෦ͬͯ͘ΕΔ STEP1 STEP2 STEP3 STEP4
URLʹΞΫηεͨ͠Βެ։͞Εͯ·͢ STEP1 STEP2 STEP3 STEP4
ϥΠϒίʔσΟϯά %
Thanks!