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
serverless - send email and update status
Search
Anna Su
March 22, 2019
Technology
0
91
serverless - send email and update status
2019/3/22
@ branch8 公司內部技術分享
Anna Su
March 22, 2019
Tweet
Share
More Decks by Anna Su
See All by Anna Su
從 Styled System 看下一代 CSS 技術
annasu
2
2.3k
We need a better UI component library - Styled System
annasu
0
6.2k
What’s FullStory?
annasu
0
130
PWA 應用與價值
annasu
0
90
初探 DevOps 的世界
annasu
0
250
Why Redux-Observable?
annasu
0
58
PWA 與 Service Worker
annasu
0
63
2016 PIXNET HACKATHON Lightning talk - 做網站不是只有一個人的事
annasu
0
77
Other Decks in Technology
See All in Technology
Scrum Fest Morioka 2026
kawaguti
PRO
2
600
「静的解析」だけで終わらせない。 SonarQube の最新機能 × AIで エンジニアの開発生産性を本気で上げる方法
xibuka
2
270
AgentCore RuntimeをVPCにデプロイして 開発ドキュメント作成AIエージェントを作った
alchemy1115
3
300
AIに視覚を与えモバイルアプリケーション開発をより円滑に行う
lycorptech_jp
PRO
1
510
AI Coding Agentの地殻変動 ~ ai-coding.info の定点観測 ~
kotauchisunsun
0
140
「技術的にできません」を越えて価値を生み出せ──研究開発チームをPMが率いて生み出した価値創出
hiro93n
1
320
サンタコンペ2025完全攻略 ~お前らの焼きなましは遅すぎる~
terryu16
1
330
器用貧乏が強みになるまで ~「なんでもやる」が導いたエンジニアとしての現在地~
kakehashi
PRO
5
520
チーム開発の基礎_研究を事業につなげるために
cyberagentdevelopers
PRO
8
4.3k
NW構成図の自動描画は何が難しいのか?/netdevnight3
corestate55
2
370
LINEヤフーにおけるAI駆動開発組織のプロデュース施策
lycorptech_jp
PRO
0
130
インシデント対応入門
grimoh
7
5.1k
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
450
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
How GitHub (no longer) Works
holman
316
140k
The agentic SEO stack - context over prompts
schlessera
0
670
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Everyday Curiosity
cassininazir
0
140
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
130
4 Signs Your Business is Dying
shpigford
187
22k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.4k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
65
Measuring & Analyzing Core Web Vitals
bluesmoon
9
760
Transcript
Serverless Anna Su Send Email and update status
Why not VM 即使 server 沒有收到任何 request ,還是會被收取費⽤用 必須設定與持續管理理 Server
需要經常更更新 Server,避免安全性問題 當我們使⽤用量量變⼤大時,需要管理理 server 的 scaling up 如果使⽤用量量變低時,也需要 scaling down
Why Serverless ⾃自動擴展 依照使⽤用量量付費 開發速度更更快 零管理理
You don’t have to think about those servers. You just
focus on code.
What’s Serverless Serverless is an execution model where the cloud
provider is responsible for executing a piece of code by dynamically allocating the resources.
What’s Serverless The code is typically run inside stateless containers.
Can be triggered by a variety of events including http requests, database events, monitoring alerts, file uploads, scheduled events, etc
How Serverless Works @aws Upload your code to AWS Lambda
Set up your code to trigger from other AWS services, HTTP endpoints, or in-app activity Lambda runs your code only when triggered, using only the compute resources needed Pay just for the compute time you use
Install Serverless npm install -g serverless
Deploy a Node.js function to AWS Lambda
sls
sls create -t aws-nodejs
brew install awscli
aws configure
module.exports.hello = async (event) => { return { statusCode: 200,
body: JSON.stringify({ message: 'Go Serverless v1.0! Your function executed successfully!', input: event, }), }; }; handler.js
service: aws-nodejs-demo provider: name: aws runtime: nodejs8.10 functions: hello: handler:
handler.hello events: - http: path: / method: get serverless.yml
sls deploy
Serverless Project for Email
HASURA SendGrid AWS Lambda Using
HASURA build GraphQL apps backed by Postgres
HASURA Event trigger
SendGrid email service trusted by developers and marketers
AWS Lambda run code without thinking about servers
Send Email HASURA event trigger webhook Serverless AWS Lambda
Update Email Status notification webhook Serverless AWS Lambda
Email Flow HASURA Realtime Serverless Send email HASURA Event SendGrid
Event Notification SendGrid Serverless Update email
Send Email Flow HASURA Realtime Serverless Send email HASURA Event
SendGrid
Create HASURA Table
Creating an event-trigger to listen to a database change on
Postgres
Create Serverless (Send Email) const sgMail = require('@sendgrid/mail'); module.exports.run =
async event => { try { let { table: { name: table_name, schema }, event: { data: { new: { to, from, subject, content: html, id }, }, }, } = JSON.parse(event.body); sgMail.setApiKey(process.env.SENDGRID_API_KEY);
SendGrid Settings
AWS Lambda Settings
Update Email Status Flow HASURA Realtime Serverless Send email HASURA
Event SendGrid Event Notification SendGrid Serverless Update email
Create Serverless (Update Email) const axios = require('axios'); module.exports.run =
async event => { try { const body = JSON.parse(event.body); const { id, event: status, schema, table_name } = body[body.length - 1]; await axios({ method: 'post', headers: { 'x-hasura-admin-secret': process.env.HASURA_SECRET, }, url: process.env.HASURA_URL, data: { variables: {
AWS Lambda Settings
SendGrid Settings
provider: functions: sendEmailFromHasura: handler: sendEmailFromHasura.run events: - http: path: send-email-from-hasura
method: post updateHasuraEmailStatus: handler: updateHasuraEmailStatus.run events: - http: path: update-hasura-email-status method: post plugins: - serverless-plugin-monorepo serverless.yml
sls deploy
AWS Lambda function
Reference https://serverless.com/ https://aws.amazon.com/tw/lambda/ Develop a Serveerless Backend using Node.js on
AWS Lambda What is Serverless ? Serverless overview What is Serverless Architecture? https://www.flaticon.com
Thanks Anna Su