Skip to content

Instantly share code, notes, and snippets.

@EITANINOMIYA
Last active March 23, 2017 02:31
Show Gist options
  • Save EITANINOMIYA/2605454cf51eba344bb4d380815d8185 to your computer and use it in GitHub Desktop.
Save EITANINOMIYA/2605454cf51eba344bb4d380815d8185 to your computer and use it in GitHub Desktop.
【Lambda】マッピングの書き方
/*#################################################
# lambdaのnodejsで接続元のIPを取得出来るようにするマッピングと
# GETパラメータを取得出来るようにするマッピングの書き方
#
# nodejsでのサンプルコードも
#################################################*/
// mapping定義ファイル
{
"sourceIp" : "$context.identity.sourceIp", // 接続元のIP
"querystring" : "$input.params().querystring",
"query" : { // GETパラメータ。
#foreach($param in $input.params().querystring.keySet())
"$param" : "$util.escapeJavaScript($input.params().querystring.get($param))" #if($foreach.hasNext),#end
#end
}
}
// nodejs
exports.handler = function(event, context, callback) {
var query = event.query;
console.log(query.hoge); // http://xxxxx.com/?hoge=123, 123が表示される
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment