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
これでLambdaが不要に?!Step FunctionsのJSONata対応について
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
TomoyaIwata
December 11, 2024
Programming
6.6k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
これでLambdaが不要に?!Step FunctionsのJSONata対応について
2024/12/11の「クラスメソッド re:Growth 2024 大阪」で発表した資料です
TomoyaIwata
December 11, 2024
More Decks by TomoyaIwata
See All by TomoyaIwata
CIで使うClaude
iwatatomoya
0
200
Lambdaの常識はどう変わる?!re:Invent 2025 before after
iwatatomoya
1
1.3k
Aurora DSQLはサーバーレスアーキテクチャの常識を変えるのか
iwatatomoya
1
2.4k
Qdrantでベクトルデータベースに入門してみよう
iwatatomoya
0
2.8k
詳解 AWS Lambdaコールドスタート
iwatatomoya
2
3.4k
真のサーバーレスへ向けたAuroraの進化Aurora Limitless Database
iwatatomoya
1
5.1k
AWS SDKのClientはFactory経由で作ろう
iwatatomoya
1
1.1k
OpentelemetryでアプリケーションのObservabilityを強化しよう
iwatatomoya
0
1.3k
AWS Lambdaは俺が作った
iwatatomoya
2
3.4k
Other Decks in Programming
See All in Programming
OS アップデート対応の取り組み方がもっと共有されてほしい
andpad
0
110
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
840
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
430
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
200
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
8.8k
継続モナドとリアクティブプログラミング
yukikurage
3
450
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
150
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
110
スマートグラスで並列バイブコーディング
hyshu
0
280
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
150
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
350
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
18k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
The Language of Interfaces
destraynor
162
27k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
260
Faster Mobile Websites
deanohume
310
32k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
450
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Six Lessons from altMBA
skipperchong
29
4.3k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Transcript
2024/12/11 リテールアプリ共創部 岩田智哉 これでLambdaが不要に?! Step FunctionsのJSONata対応について
自己紹介 • 産業支援グループ リテールアプリ共創部 • 2018年5月入社 • 普段は主にサーバーサイドの開発に従事 • 前十字靭帯再建手術リハビリ中のためre:Invent不参加
岩田 智哉
re:Invent直前にStep Functionsのアップデート • 変数のサポート • JSONataのサポート https://aws.amazon.com/about-aws/whats-new/2024/11/aws-step-functions-variables-jsonata-transformations/
JSONata(じぇいそなーた) JSONをクエリ・変換するための言語 今後Step FunctionsではJSONataが推奨に
JSONata Exerciserでサクッと動作確認可能 https://try.jsonata.org/
Step Functionsのマネコンでもテスト可能
LocalStackでもテスト可能 Step Functions Made Easy in AWS and LocalStack https://blog.localstack.cloud/aws-step-functions-made-easy/
LocalStack V4.0.1からJSONataに対応
何が嬉しいのか?? 従来はLambdaが必要だった整形処理が JSONataだけで実現可能に!!
従来のStep Functionss組み込み関数 組み込み関数 説明 States.Array 配列を生成する States.ArrayPartition 配列を配列の配列に分割する States.ArrayContains 特定の値が配列に存在するかどうか返す
States.ArrayRange 特定の範囲の要素を含む配列を作成する States.ArrayGetItem 配列の指定されたインデックスの値を返す States.ArrayLength 配列の長さを返す States.ArrayUnique 配列から重複する値を削除して一意の要素のみを含む配列を返す States.Base64Encode MIME Base64でをエンコードする States.Base64Decode MIME Base64でデコードする States.Format 文字列のフォーマット States.Hash ハッシュ値を計算する States.JsonMerge 2 つの JSON オブジェクトを 1 つのオブジェクトにマージする States.MathRandom 指定された開始番号と終了番号の間の乱数を返す States.MathAdd 2 つの数値の合計を返す States.StringSplit 文字列を配列に分割する States.StringToJson JSON文字列をオブジェクトにパース States.UUID UUID v4 を返す https://docs.aws.amazon.com/step-functions/latest/dg/intrinsic-functions.html
従来の組み込み関数だけで対応できないケースも Lambda無しで乗算を実現しようと思うと… AWS Step Functionsで組み込み関数だけを使って整数の乗算を実装してみた(AWS CDK) https://dev.classmethod.jp/articles/aws-step-functions-14-new-intrinsic-features-process-data-workflows/
JSONataを使うと乗算も楽々
JSONataでできること概要 • クエリ • 正規表現 • 文字列操作 • 日付操作 •
四則演算 • 簡易なプログラミング …etc
JSONataによるプログラミング
変数が使える
条件分岐も可能 三項演算子で条件分岐可能
自分で関数も定義できる functionで独自に関数を定義可能
関数のチェイン ~> を使って関数をチェインできる
豊富な関数群 • String : $string(),$length(), $substring()…etc • Numeric : $number(),$abs(),
$floor(), $ceil()…etc • Aggregation : $sum(),$max(),$min(),$average() • Boolean : $boolean(),$not(),$exists() • Array : $count(),$append(),$sort(),$reverse(),$shuffule(),$distinct(),$zip() • Object : $keys(),$lookup(),$spread(),$merge(),$sift(),$each()…etc • Date/Time: $now(),$millis(), $fromMillis(), $toMillis(), • Higher Order : $map(), $filter(), $single(), $reduce(), $sift()
Step Functionsで使える追加の関数-1 • $partition ◦ 指定したチャンクサイズで配列を分割して配列の配列を作る ◦ $partition([1,2,3,4,5,6,7,8,9,10],2) → [[1,2],[3,4],[5,6],[7,8],[9,10]]
• $range ◦ 指定した範囲を含む配列を生成する ◦ $range(1, 10, 2) → [1,3,5,7,9] • $hash ◦ ハッシュ値を計算する ◦ $hash("hoge", "MD5") → "ea703e7aa1efda0064eaa507d9e8ab7e"
Step Functionsで使える追加の関数-2 • $random ◦ 指定された範囲の乱数を生成 ◦ $random() → 0.29852901560666767
• $uuid ◦ UUIDV4を生成 ◦ $uuid() → "7d3f8238-5326-4072-aba6-732b8e9632f3" • $parse ◦ JSON文字列をパースする ◦ $parse("{∖"key∖": ∖"val∖"}") → {"key": "val"}
実装例
JSONataでできること SlackへのAWS料金通知を(ほぼ)Step Functionsの機能だけで作ってみた https://dev.classmethod.jp/articles/step-functions-cost-notify/ 同僚の小倉さんによるJSONata活用例
前月の末日を計算
AWSアカウントIDでグルーピング
まとめ
まとめ • JSONataによってLambda無しでできることの 幅が大きく広がった • 曲芸的な使い方もできるのでやりすぎ注意 • JSONata曲芸選手権みたいなのも面白そう
None