Reputation: 180
I have an API Gateway to Lambda integration. In integration template I would like to check one of the input params and depending on it's value, I would like to set field in event that gets passed to Lambda. For that I wrote integration template but it always seems to go in else case even when I pass 'ext-prod-live' as environment in POST request. So my event['stage_variables']['solr_url'] is always $stageVariables.solr_url. I think that I am not accessing POST body correctly and getting "" back from $input.params('environment').
Template
#set($inputJson = $input.json('$')) { "request" : $inputJson, "Authorization" : "$input.params().header.get('Authorization')",
#if ( $input.params('environment') == "ext-prod-live" ) "stage_variables" : {"solr_url" : "$stageVariables.live_solr_url"}
#else "stage_variables" : {"solr_url" : "$stageVariables.solr_url"}
#end }
Request body
{"environment": "ext-prod-sim", "min_ts": 0,
"execType": 14}
Any help is much appreciated.
Upvotes: 2
Views: 2732
Reputation: 180
After some research I figured out that I had to use the velocity template language and path to access POST payload correctly. basically changed "$input.params('environment')" to "$input.path('$.environment')"
Upvotes: 4