Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
これでLambdaが不要に?!Step FunctionsのJSONata対応について
Search
TomoyaIwata
December 11, 2024
Programming
6.8k
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
Transcript
27 slides
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
More Decks by TomoyaIwata
See All by TomoyaIwata
サーバーフルコンピューティング?AWS Lambda
iwatatomoya
1
620
CIで使うClaude
iwatatomoya
0
590
Lambdaの常識はどう変わる?!re:Invent 2025 before after
iwatatomoya
1
1.4k
Aurora DSQLはサーバーレスアーキテクチャの常識を変えるのか
iwatatomoya
1
2.7k
Qdrantでベクトルデータベースに入門してみよう
iwatatomoya
0
3.2k
詳解 AWS Lambdaコールドスタート
iwatatomoya
2
3.6k
真のサーバーレスへ向けたAuroraの進化Aurora Limitless Database
iwatatomoya
1
5.2k
AWS SDKのClientはFactory経由で作ろう
iwatatomoya
1
1.2k
OpentelemetryでアプリケーションのObservabilityを強化しよう
iwatatomoya
0
1.4k
Other Decks in Programming
See All in Programming
AI Augmentation Techniques with Liberty
ivargrimstad
1
440
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
9k
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
240
Next.js: The final boss of Web Performance
guaca
0
400
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
370
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
120
SODA - FACT BOOK(EN)
sodainc
1
230
ActionController meets Protocol Buffers
sorah
1
800
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
170
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
600
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
Claude Code のすすめ
schroneko
67
230k
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
560
How to Ace a Technical Interview
jacobian
280
24k
Building the Perfect Custom Keyboard
takai
2
950
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
350
Abbi's Birthday
coloredviolet
5
11k
Docker and Python
trallard
47
4.3k