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
Go on lambda
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
translucens
May 28, 2018
Programming
670
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go on lambda
Lightning talk about Go and AWS Lambda at merpay
translucens
May 28, 2018
More Decks by translucens
See All by translucens
12 Factor App on Kubernetes を12ヶ月実践して見えてきたもの
translucens
4
1.4k
The Twelve-Factor AppとKubernetes
translucens
6
1.4k
Qicoo app Frontend
translucens
0
610
Other Decks in Programming
See All in Programming
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
19k
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
270
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
250
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
1
130
Built Our Own Background Agent at LayerX
layerx
PRO
10
6k
Dockerfile CMD for Node.js
grazie1999
0
110
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
370
typoなんかねぇよ
raspython3
0
400
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
280
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
510
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
100
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Practical Orchestrator
shlominoach
191
12k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Documentation Writing (for coders)
carmenintech
77
5.5k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
500
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.5k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
270
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
490
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
A Soul's Torment
seathinner
6
3.5k
Transcript
Go on AWS Lambda May 28, 2018 @merpay Soichiro Kawamura
Certain Enterprise @translucens
•$whoami • 某エンタープライズ企業 アジャイル推進部門所属 ◦ クラウドネイティブ設計、ChatOpsの布教 ◦ その前はオンプレで金融システム開発 • 道場に来た理由
◦ ドイツ拠点CTOがGoは軽量、型安全で最高!と 強く推しているので来ました ◦ ちょっとした業務改善アプリでK8sのYAMLを全部書くのはつらい →Serverlessでアプリを作りたい • 趣味 ◦ 写真、航空マイル集め、ガジェット
None
•Development over the Cloud • 「クラウドの上で」開発
•Go on Serverless platform • 型安全であり、ネイティブバイナリが生成できて 起動の速いGoはServerlessに最適 ◦ コンテナの起動に10秒以上かかる言語☕もある •
2018年になり、AWS LambdaがGoをサポート、 デプロイに使うSAMテンプレートの自動生成も可能に ◦ SAMはCloudFormationのLambda用の拡張 ◦ 他のスクリプト言語と違い、Web IDEが使えないのでSAMは必須 https://aws.amazon.com/about-aws/whats- new/2018/01/aws-lambda-supports-go/ https://aws.amazon.com/about-aws/whats- new/2018/04/aws-sam-cli-releases-new-init-command/
Preparation - sam init command $ pip install aws-sam-cli --user
$ sam init --runtime go1.x $ cd sam-app $ tree . ├── hello-world │ ├── main.go │ └── main_test.go ├── Makefile ├── README.md └── template.yaml 単にSAMのテンプレ だけでなく、 必要なコード類を 一式作ってくれる
Scaffold made by sam init AWS Lambda Lambda function Amazon
API Gateway AWS X-Ray https://checkip.amazonaws.com 2. 起動 1. GET /hello 監視 3. GET / 4. “192.0.2.1” 5. “Hello, 192.0.2.1” 6. “Hello, 192.0.2.1”
How to deploy AWS Lambda 1. $go build 2. S3バケット作成(初回のみ)
3. パッケージング(バイナリのアップロード) $sam package AWS CloudFormation 4. デプロイ $sam deploy SAM template Packaged SAM template Amazon API Gateway 自動作成
Developing Program Lambda X-Ray 監視 email SES us-west-2 (Oregon) SNS
SNS Lambda ap-northeast-1 (Tokyo) • BASE64デコード • メール→JSON変換 JSON→ SlackへのPOST
Developing Program w/ Future works Lambda email SES us-west-2 (Oregon)
EC2 SNS SNS Lambda ap-northeast-1 (Tokyo) GuardDuty Event Lambda SNS Lambda 深刻度に応じた チケット優先度の設定 ルーティング情報は SNSに集約
•Demo
•Pitfalls • 既存のS3バケットをSAMに指定できない • SESからLambdaを 直接起動する場合 ◦ 本文がJSONに含まれない ◦ 他リージョンは指定不可
• SESのテストメールが BASE64を指定しても UTF-8で送信されてBASE64デコードがこける
•Thanks JSON→Go Converter! • https://mholt.github.io/json-to-go/