Get aws lambda response as an HTML page

ARUNBALAN NV picture ARUNBALAN NV · Aug 3, 2015 · Viewed 11.5k times · Source

How can i get the aws lambda response as the HTML page. Please provide the step wise procedure to solve this.

Answer

ARUNBALAN NV picture ARUNBALAN NV · Aug 11, 2015

Store the HTML markup in a variable and return it to avoid the text being wrapped in quotes. First store your HTML markup in a variable in the lambda function then return it. For example in Node.js:

context.succeed({ variableHTML: myContentHtml })

Here is an example of the mapping template:

#set($inputRoot = $input.path('$')) $inputRoot.variableHTML .

Here variableHTML contains the HTML markup passed from the lambda function. After that you needed to create an Response model for HTTP Status, which is accessible through Method Response. Here set the Response model Content-Type as text/html. Then you'll get the HTML page without quotes and the browser recognizes it as HTML.