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
translucens
May 28, 2018
Programming
2
590
Go on lambda
Lightning talk about Go and AWS Lambda at merpay
translucens
May 28, 2018
Tweet
Share
More Decks by translucens
See All by translucens
12 Factor App on Kubernetes を12ヶ月実践して見えてきたもの
translucens
3
1.3k
The Twelve-Factor AppとKubernetes
translucens
6
1.3k
Qicoo app Frontend
translucens
0
530
Other Decks in Programming
See All in Programming
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
Bedrock Agentsレスポンス解析によるAgentのOps
licux
2
720
パスキーのすべて ── 導入・UX設計・実装の紹介 / 20250213 パスキー開発者の集い
kuralab
3
670
[Fin-JAWS 第38回 ~re:Invent 2024 金融re:Cap~]FaultInjectionServiceアップデート@pre:Invent2024
shintaro_fukatsu
0
400
AWS Lambda functions with C# 用の Dev Container Template を作ってみた件
mappie_kochi
0
240
AHC041解説
terryu16
0
590
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
1
170
Amazon Q Developer Proで効率化するAPI開発入門
seike460
PRO
0
110
Honoのおもしろいミドルウェアをみてみよう
yusukebe
1
200
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
41
15k
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
10
1.8k
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
640
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
99
18k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
29
2.2k
A better future with KSS
kneath
238
17k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
KATA
mclloyd
29
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
31
2.1k
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/