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
600
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
4
1.3k
The Twelve-Factor AppとKubernetes
translucens
6
1.4k
Qicoo app Frontend
translucens
0
540
Other Decks in Programming
See All in Programming
eBPF超入門「o11yに使える」とは (20250424_eBPF_o11y)
thousanda
1
120
Laravel × Clean Architecture
bumptakayuki
PRO
0
150
Ruby で作る RISC-V CPU エミュレーター / RISC-V CPU emulator made with Ruby
hayaokimura
5
1k
エンジニアが挑む、限界までの越境
nealle
1
330
「理解」を重視したAI活用開発
fast_doctor
0
300
データベースの技術選定を突き詰める ~複数事例から考える最適なデータベースの選び方~
nnaka2992
0
140
七輪ライブラリー: Claude AI で作る Next.js アプリ
suneo3476
1
190
ComposeでのPicture in Picture
takathemax
0
130
M5UnitUnified 最新動向 2025/05
gob
0
140
LRパーサーはいいぞ
ydah
6
1.3k
音声プラットフォームのアーキテクチャ変遷から学ぶ、クラウドネイティブなバッチ処理 (20250422_CNDS2025_Batch_Architecture)
thousanda
0
410
note の Elasticsearch 更新系を支える技術
tchov
9
3.6k
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Typedesign – Prime Four
hannesfritz
41
2.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
23
2.7k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
600
YesSQL, Process and Tooling at Scale
rocio
172
14k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
179
53k
Code Reviewing Like a Champion
maltzj
523
40k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
The Language of Interfaces
destraynor
158
25k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
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/