
Matched event (一致したイベント)
イベント全体をそのまま渡す。
Part of the matched event (一致したイベントの一部)
- CloudFormation property: InputPath
イベントの一部をJSONPath形式で指定して渡す。複数指定不可。
$.detail
Constant (JSON text) (定数 JSONテキスト)
- CloudFormation property: Input
任意のJSON文字列をJSON形式で渡す。
{ "key": "value", "hoge": [ 1, true, "fuga" ] }
Input Transformer (インプットトランスフォーマー)
- CloudFormation property: InputTransformer
- InputPathsMap
- InputTemplate
テンプレートに基づいた 文字列 を渡す
Input Path
Key-Value形式でJSONPath(ドット表記)を記述。
{ "state": "$.detail.state", "instance": "$.detail.instance-id" }
Input Template
渡される文字列のテンプレート。Input Path 定義(プレースホルダ)は "<>" で囲む。
"The state of Instance <instance> is <state>"
Lambda 内でJSON形式で利用する
Input Template に JSON文字列 を定義し、
JSON文字列 として渡し、Lambda側で変換する。
- ダブルクォーテーションで囲む
- 内部のダブルクォーテーションをエスケープ
- 改行不可
"{ \"DetailType\": \"<DetailType>\", \"Source\": \"<Source>\" }"
Python
- Input Transformer 以外は dict で渡る
import json
def lambda_handler(event, context):
if type(event) == str:
event = json.loads(event)
Node.js
- Input Transformer 以外は object で渡る
exports.handler = async (event) => {
if (typeof(event) == "string") {
event = JSON.parse(event);
}
};