{"id":94,"date":"2017-08-24T17:27:59","date_gmt":"2017-08-24T11:57:59","guid":{"rendered":"https:\/\/www.ecomm.in\/blog\/?p=94"},"modified":"2017-08-25T23:33:27","modified_gmt":"2017-08-25T18:03:27","slug":"less-server-more-serverless-creating-your-first-aws-lambda-function","status":"publish","type":"post","link":"https:\/\/www.ecomm.in\/blog\/less-server-more-serverless-creating-your-first-aws-lambda-function\/","title":{"rendered":"Serverless Future: Creating your first AWS Lambda function"},"content":{"rendered":"<p>Howdy techies! I&#8217;m Tanmay with the DevOps team at Ecomm India Cloud IT which helps companies with <a href=\"https:\/\/www.ecomm.in\">cloud transformation<\/a> and DevOps processes on top of cloud Platforms like AWS. Part of what I do everyday is help organizations drastically increase their pace of innovation by removing bottlenecks with DevOps pipelines that increase their performance efficiency and reduce cost.<\/p>\n<p>I have been working on few exciting projects in the recent months involving Rest API\u2019s and Serverless architecture. I thought I would share with you some of the serverless tools and techniques that i have learnt which might help you with your future projects.<\/p>\n<p>So, in this article I will be showing you how to create a serverless function and a rest api to trigger this serverless function. For this I will be using <a href=\"https:\/\/console.aws.amazon.com\/console\/\">Amazon Web Services Lambda and API Gateway<\/a>. I will be creating a basic Even Odd Function using python environment, where the function will determine whether the user input is even or odd. I am selecting a very basic function, so that anybody can use this article to start learning Lambda function and API gateway without needing too much coding experience. However, it is recommended that the user should know basics of AWS. If you are new to cloud computing and want to make a career in it, I recommend you to visit <a href=\"https:\/\/www.ecomm.in\/training\/course\/aws-solutions-architect\/\">AWS training<\/a> section on our website for more hands-on training on AWS.<\/p>\n<h2>So, what is serverless computing?<\/h2>\n<p>About a decade ago or physical servers were still in demand, thanks to cloud servers that is no longer the case, technically the physical servers still do exist it\u2019s just that you don\u2019t need to manage them as they are either automated or managed by a service provider at a very low cost. And now serverless is abstracting cloud servers.<\/p>\n<p>Serverless architecture is defined by stateless compute containers and modeled for an event-driven solution. AWS Lambda is the perfect example of serverless architecture and employs <strong>Functions as a service (FaaS)<\/strong> model of cloud computing. Platform as a Service (PaaS) architectures popularized by Salesforce Heroku, AWS Elastic Beanstalk and Microsoft Azure simplify applications deployment for developers. <strong>And serverless architecture or FaaS is the next step in that direction.<\/strong><\/p>\n<h2>Advantage of going serverless<\/h2>\n<p>Main advantage is that you no longer need to keep a cloud server \/ instance running all the time. The serverless compute capacity appears when you need it, then disappears when you\u2019re done with it just like a function and all your business logic can now live within these functions.<\/p>\n<h2>So, what can you do with Lambda Functions?<\/h2>\n<p>You can do a simple echo function, to a fully operational automated chatbot for your website, possibilities are endless.<\/p>\n<p>Before we get our hands dirty here are few things that you require to create your first lambda function:<\/p>\n<ol>\n<li>First, you\u2019ll need an AWS account. If you don\u2019t have one yet, start by opening a free AWS account <a href=\"https:\/\/aws.amazon.com\/free\">here<\/a>. AWS has a free tier that\u2019s more than enough for what you will need for this tutorial.<\/li>\n<li>Basic understanding of programming environment, AWS Lambda currently supports code written in <strong>js<\/strong> (<strong>JavaScript<\/strong>), Python, <strong>Java<\/strong> (<strong>Java 8<\/strong> compatible), and C# (.NET Core). Your code can include existing libraries, even native ones. Please read AWS documentation on using <strong>Node.js<\/strong>, Python, <strong>Java<\/strong>, and C#.<\/li>\n<\/ol>\n<p>Once you are done with setting up your AWS Account we can move on to creating our even odd function in python 2.7 environment using AWS Lambda and API gateway.<\/p>\n<h2>Getting Started<\/h2>\n<p>Right, now that we have the basic things in order, we can dig in! To get started, login to your <a href=\"https:\/\/console.aws.amazon.com\/console\/home\">AWS Management console<\/a>, once done you should see a screen like below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-96 size-full\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/1.jpg\" alt=\"\" width=\"1317\" height=\"406\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/1.jpg 1317w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/1-300x92.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/1-768x237.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/1-1024x316.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/1-800x247.jpg 800w\" sizes=\"auto, (max-width: 1317px) 100vw, 1317px\" \/><\/p>\n<p>Make a note of the region you are working in, as all your resources will be created in this region. I\u2019m using \u201cUS-East-2\u201d region that is \u201cOhio\u201d. <a href=\"http:\/\/docs.aws.amazon.com\/general\/latest\/gr\/rande.html\">Click here or more information on regions and availability zones.<\/a><\/p>\n<h2>AWS Lambda Function<\/h2>\n<p>To start with the coding click on the Lambda link present under Compute section or just write in the text bar provided below AWS Services title. For this post, I am creating a function which will check whether the given number is even or odd.<\/p>\n<p>You should see below page if you have never used AWS Lambda before, from here you can quickly access documentation related to Lambda, find out its cost or could learn new features. Take your time to go through these details before proceeding to create a function.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-98\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/2.jpg\" alt=\"\" width=\"924\" height=\"531\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/2.jpg 924w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/2-300x172.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/2-768x441.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/2-800x460.jpg 800w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><\/p>\n<h3>Blueprint<\/h3>\n<p>Once you are ready click on the create a function on the top right corner of this page.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-99\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/3.jpg\" alt=\"\" width=\"1277\" height=\"426\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/3.jpg 1277w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/3-300x100.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/3-768x256.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/3-1024x342.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/3-800x267.jpg 800w\" sizes=\"auto, (max-width: 1277px) 100vw, 1277px\" \/><\/p>\n<p>You can see some sample blueprints on this screen to start off with or can start from scratch, for this blog I will start from scratch.<\/p>\n<p>After you click author from scratch you should get below screen.<\/p>\n<h3>Triggers<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-101\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/4.jpg\" alt=\"\" width=\"1260\" height=\"504\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/4.jpg 1260w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/4-300x120.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/4-768x307.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/4-1024x410.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/4-800x320.jpg 800w\" sizes=\"auto, (max-width: 1260px) 100vw, 1260px\" \/><\/p>\n<p>Here you can configure the triggers which will call this Lambda function and give you the result depending on the code, you can choose from a few options. \u00a0I will be using API Gateway as the trigger method, this way we can test the Lambda function from our browser. So, update the values as shown below. Please note for simplicity reasons I am keeping the security open, it is recommended that you use either AWS IAM or Access ID &amp; Code for securing your API from other users. That is advanced method and we shall cover that later. Once you are done with making changes to your screen click next.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-102\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/5.jpg\" alt=\"\" width=\"659\" height=\"510\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/5.jpg 659w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/5-300x232.jpg 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/p>\n<h3>Configure Function<\/h3>\n<p>After this click next, you should get below screen.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-103\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/6.jpg\" alt=\"\" width=\"995\" height=\"387\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/6.jpg 995w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/6-300x117.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/6-768x299.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/6-800x311.jpg 800w\" sizes=\"auto, (max-width: 995px) 100vw, 995px\" \/><\/p>\n<p>Change the runtime environment from Node.js 6.10 to Python 2.7 as I am providing the code in python language. Make sure you give an appropriate Name to the function and an optional description. \u00a0I have updated the Name and Description of the function to indicate its purpose.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-104\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/7.jpg\" alt=\"\" width=\"990\" height=\"390\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/7.jpg 990w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/7-300x118.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/7-768x303.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/7-800x315.jpg 800w\" sizes=\"auto, (max-width: 990px) 100vw, 990px\" \/><\/p>\n<p>Once you are done, scroll down to start with your code.<\/p>\n<h3>Code<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-105\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/8.jpg\" alt=\"\" width=\"666\" height=\"497\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/8.jpg 666w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/8-300x224.jpg 300w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/p>\n<pre>def lambda_handler(event, context):\r\n\r\n\u00a0\u00a0\u00a0 #We are accepting a number from the user and storing it in variable num.\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 num = event['number']\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #The % operator is the modulo, which returns the remainder rather than the quotient after division.\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 res = num % 2\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if res == 0:\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 #Check whether the remainder is 0 if so set the return message to even.\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ret = \"%d Number is an even number!\" %(num)\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else:\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 #set the return message to odd.\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ret = \"%d Number is an odd number!\" %(num)\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return ret<\/pre>\n<h3><\/h3>\n<h3>Handler &amp; Permissions<\/h3>\n<p>Once you are done writing the code make sure you set the handler name with function.lambda_handler where function is the name of your function, for me its evenodd hence my handler is evenodd.lambda_handler. Next step is to create a role to allow this lambda to execute the function, select an appropriate name for the role and attach policy template by typing lambda inside the dropdown box indicated by the arrow, you should select \u201cBasic Edge Lambda Permissions\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-106\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/9.jpg\" alt=\"\" width=\"790\" height=\"501\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/9.jpg 790w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/9-300x190.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/9-768x487.jpg 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/p>\n<p>Scroll down and click on advanced settings and edit the time out from 3 seconds to 30 seconds.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-107\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/10.jpg\" alt=\"\" width=\"697\" height=\"551\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/10.jpg 697w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/10-300x237.jpg 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/p>\n<p>Leave all other things to default. After that click, next and you should see below screen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-108\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/11.jpg\" alt=\"\" width=\"757\" height=\"629\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/11.jpg 757w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/11-300x249.jpg 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/p>\n<p>Finally click on the create function button.<\/p>\n<h3>Testing<\/h3>\n<p>Next step is to click on Test button, edit the test document as shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-109\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/12.jpg\" alt=\"\" width=\"657\" height=\"516\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/12.jpg 657w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/12-300x236.jpg 300w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><\/p>\n<p>And click save and test. You should see a window similar to below window:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-110\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/13.jpg\" alt=\"\" width=\"819\" height=\"567\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/13.jpg 819w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/13-300x208.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/13-768x532.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/13-800x554.jpg 800w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<p>If you get execution result as succeeded then that means our function is working as expected.<\/p>\n<p>We have tested the function from within the lambda function for complete functionality we have a trigger to invoke this lambda function from outside of the AWS. But first we need to update a few things in our API gateway.<\/p>\n<h2>API Gateway<\/h2>\n<p>Click on API Gateway it is in the Application Services section, or you can write API Gateway in the text bar at the top. Once you open API Gateway you should get below screen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-111\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/14.jpg\" alt=\"\" width=\"614\" height=\"587\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/14.jpg 614w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/14-300x287.jpg 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/p>\n<p>You can see that the lambda function has already created an API for us as we defined it in the trigger section declaration of lambda function. So, click on this API to get started.<\/p>\n<h3>Create Methods<\/h3>\n<p>Click on the resource (\/evenodd) to see below screen<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-112\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/15.jpg\" alt=\"\" width=\"503\" height=\"240\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/15.jpg 503w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/15-300x143.jpg 300w\" sizes=\"auto, (max-width: 503px) 100vw, 503px\" \/><\/p>\n<p>By default, when you create a trigger of API Gateway from Lambda function it creates the any method for its execution. However, I am going to create a new method to use this API gateway. First, I will create a Get method and later I will create a POST method. To start this process, click on the action button at the top and select create method<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-113\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/16.jpg\" alt=\"\" width=\"672\" height=\"462\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/16.jpg 672w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/16-300x206.jpg 300w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/p>\n<h4>GET Method<\/h4>\n<p>Select GET Method from the dropdown list.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-157\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/17-1.jpg\" alt=\"\" width=\"751\" height=\"400\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/17-1.jpg 751w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/17-1-300x160.jpg 300w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/p>\n<p>In here use the integration type as Lambda function and then select the Lambda region that you have used to create your lambda in, for me it was US-EAST-2 (Ohio) so my settings are like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-115\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/18.jpg\" alt=\"\" width=\"718\" height=\"305\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/18.jpg 718w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/18-300x127.jpg 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-116 size-full\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/19.jpg\" alt=\"\" width=\"283\" height=\"191\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/19.jpg 283w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/19-120x80.jpg 120w\" sizes=\"auto, (max-width: 283px) 100vw, 283px\" \/><\/p>\n<p>Once you are done with updating the details, click next and you\u2019d get a pop up like below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-117\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/20.jpg\" alt=\"\" width=\"468\" height=\"185\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/20.jpg 468w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/20-300x119.jpg 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/p>\n<p>click ok on this message to get a screen like below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-118\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/21.jpg\" alt=\"\" width=\"1336\" height=\"470\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/21.jpg 1336w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/21-300x106.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/21-768x270.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/21-1024x360.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/21-800x281.jpg 800w\" sizes=\"auto, (max-width: 1336px) 100vw, 1336px\" \/><\/p>\n<p>Now click on the Integration Request link highlighted in the below image:<\/p>\n<h5>Integration Request<\/h5>\n<p>You should get a screen like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-119\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/22.jpg\" alt=\"\" width=\"1003\" height=\"431\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/22.jpg 1003w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/22-300x129.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/22-768x330.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/22-800x344.jpg 800w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-120\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/23.jpg\" alt=\"\" width=\"748\" height=\"542\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/23.jpg 748w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/23-300x217.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/23-90x65.jpg 90w\" sizes=\"auto, (max-width: 748px) 100vw, 748px\" \/><\/p>\n<p>Now click on the arrow next to \u201cBody Mapping Templates\u201d<\/p>\n<p>&nbsp;<\/p>\n<h5>Body Mapping Templates<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-121\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/24.jpg\" alt=\"\" width=\"617\" height=\"254\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/24.jpg 617w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/24-300x124.jpg 300w\" sizes=\"auto, (max-width: 617px) 100vw, 617px\" \/><\/p>\n<p>By default, there are no templates defined, so select second option on \u201cRequest Body Passthrough\u201d that is when there are no templates defined (Recommended) option and click on add mapping templates.<\/p>\n<p>You should get a box like below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-122\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/25.jpg\" alt=\"\" width=\"410\" height=\"112\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/25.jpg 410w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/25-300x82.jpg 300w\" sizes=\"auto, (max-width: 410px) 100vw, 410px\" \/><\/p>\n<p>By default, the content-type suggested is application\/json but it is greyed out so you will need to type it in that box and click on the tick next to it. Once done write in the template section as shown in the below snapshot, and click save. Template field contains:<\/p>\n<pre>{\"number\" : $input.params('number')}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-123\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/26.jpg\" alt=\"\" width=\"598\" height=\"550\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/26.jpg 598w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/26-300x276.jpg 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/p>\n<h5>Deployment<\/h5>\n<p>Once done click on the actions button at the top and select deploy API to get below screen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-124\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/27.jpg\" alt=\"\" width=\"472\" height=\"258\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/27.jpg 472w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/27-300x164.jpg 300w\" sizes=\"auto, (max-width: 472px) 100vw, 472px\" \/><\/p>\n<p>You can select a new stage or select an existing stage to overwrite it. I am overwriting the Prod stage, once done click deploy.<\/p>\n<p>Once you click deploy you should be redirected to the stages click on the stage to expand it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-125\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/28.jpg\" alt=\"\" width=\"1056\" height=\"303\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/28.jpg 1056w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/28-300x86.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/28-768x220.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/28-1024x294.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/28-800x230.jpg 800w\" sizes=\"auto, (max-width: 1056px) 100vw, 1056px\" \/><\/p>\n<p>Select the method that was created (Get), copy the invoke URL path and add \u201c?number=20\u201d to it and paste it in a new browser window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-126\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/29.png\" alt=\"\" width=\"1145\" height=\"219\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/29.png 1145w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/29-300x57.png 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/29-768x147.png 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/29-1024x196.png 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/29-800x153.png 800w\" sizes=\"auto, (max-width: 1145px) 100vw, 1145px\" \/><\/p>\n<pre><a href=\"https:\/\/n79ttbsqyf.execute-api.us-east-2.amazonaws.com\/prod\/evenodd?number=20\">https:\/\/n79ttbsqyf.execute-api.us-east-2.amazonaws.com\/prod\/evenodd?number=20<\/a><\/pre>\n<p>*** replace above link with your link and use this endpoint. ***<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-127\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/30.jpg\" alt=\"\" width=\"686\" height=\"226\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/30.jpg 686w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/30-300x99.jpg 300w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><\/p>\n<p>Similarly, you can change the value of the number in the above link and you can check any number.<\/p>\n<pre><a href=\"https:\/\/n79ttbsqyf.execute-api.us-east-2.amazonaws.com\/prod\/evenodd?number=11\">https:\/\/n79ttbsqyf.execute-api.us-east-2.amazonaws.com\/prod\/evenodd?number=11<\/a><\/pre>\n<p>*** replace above link with your link and use this endpoint. ***<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-128\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/31.jpg\" alt=\"\" width=\"912\" height=\"324\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/31.jpg 912w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/31-300x107.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/31-768x273.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/31-800x284.jpg 800w\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" \/><\/p>\n<p>This way we know that our function can be called using the Get method.<\/p>\n<h3>POST Method<\/h3>\n<p>We can also use the POST method to invoke our function. To create the post method go back to API Gateway Console. Select the API, click on resources and expand the methods. Once you do that you should get below window:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-129\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/32.jpg\" alt=\"\" width=\"1013\" height=\"309\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/32.jpg 1013w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/32-300x92.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/32-768x234.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/32-800x244.jpg 800w\" sizes=\"auto, (max-width: 1013px) 100vw, 1013px\" \/><\/p>\n<p>Click on Actions button and select create method and select POST method from the dropdown list. And update the details like we did for the Get method. Once done hit save and you will get a pop like below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-130\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/33.jpg\" alt=\"\" width=\"1338\" height=\"325\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/33.jpg 1338w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/33-300x73.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/33-768x187.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/33-1024x249.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/33-800x194.jpg 800w\" sizes=\"auto, (max-width: 1338px) 100vw, 1338px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Click ok on this pop up message.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-131\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/34.jpg\" alt=\"\" width=\"468\" height=\"185\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/34.jpg 468w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/34-300x119.jpg 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/p>\n<h4>Integration Request<\/h4>\n<p>Once you click ok you should get a screen like below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-132\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/35.jpg\" alt=\"\" width=\"1332\" height=\"422\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/35.jpg 1332w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/35-300x95.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/35-768x243.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/35-1024x324.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/35-800x253.jpg 800w\" sizes=\"auto, (max-width: 1332px) 100vw, 1332px\" \/><\/p>\n<p>We will be repeating steps that we did in the Get method.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-133\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/36.jpg\" alt=\"\" width=\"1338\" height=\"482\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/36.jpg 1338w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/36-300x108.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/36-768x277.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/36-1024x369.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/36-800x288.jpg 800w\" sizes=\"auto, (max-width: 1338px) 100vw, 1338px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4>Body mapping templates<\/h4>\n<p>Now click on the Integration Request link that you see. Scroll down after you have clicked till you find Body mapping templates.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-134\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/37.jpg\" alt=\"\" width=\"650\" height=\"482\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/37.jpg 650w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/37-300x222.jpg 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>By default, there is no body mapping template defined, this template is used to parse the response that you get from Lambda function to a user readable format, without this the API Gateway will not be able to reproduce the response of the lambda function.<\/p>\n<p>So, click on the add mapping template and select below options:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-122\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/25.jpg\" alt=\"\" width=\"410\" height=\"112\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/25.jpg 410w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/25-300x82.jpg 300w\" sizes=\"auto, (max-width: 410px) 100vw, 410px\" \/><\/p>\n<p>By default, the content-type suggested is application\/json but it is greyed out so you will need to type it in that box and click on the tick next to it. Once done write in the template section as shown in the below snapshot, and click save. Template field contains: {&#8220;number&#8221; : $input.params(&#8216;number&#8217;)}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-135\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/38.jpg\" alt=\"\" width=\"598\" height=\"550\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/38.jpg 598w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/38-300x276.jpg 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/p>\n<p>Once done click save.<\/p>\n<p>Click on \u201cMethod Execution\u201d button to go back to the POST method page.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-136\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/39.jpg\" alt=\"\" width=\"693\" height=\"542\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/39.jpg 693w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/39-300x235.jpg 300w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/p>\n<h4>Integration Response<\/h4>\n<p>Now click on \u201cIntegration Response\u201d link<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-137\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/40.jpg\" alt=\"\" width=\"980\" height=\"403\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/40.jpg 980w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/40-300x123.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/40-768x316.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/40-800x329.jpg 800w\" sizes=\"auto, (max-width: 980px) 100vw, 980px\" \/><\/p>\n<p>You should see a screen like below, click on the highlighted arrow.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-138\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/41.jpg\" alt=\"\" width=\"998\" height=\"204\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/41.jpg 998w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/41-300x61.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/41-768x157.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/41-800x164.jpg 800w\" sizes=\"auto, (max-width: 998px) 100vw, 998px\" \/><\/p>\n<p>You should get a screen like below, click on the highlighted part.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-139\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/42.jpg\" alt=\"\" width=\"1002\" height=\"283\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/42.jpg 1002w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/42-300x85.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/42-768x217.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/42-800x226.jpg 800w\" sizes=\"auto, (max-width: 1002px) 100vw, 1002px\" \/><\/p>\n<p>And select \u201cConvert to text (if needed)\u201d from the dropdown list and hit save.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-140\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/43.jpg\" alt=\"\" width=\"1168\" height=\"395\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/43.jpg 1168w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/43-300x101.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/43-768x260.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/43-1024x346.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/43-800x271.jpg 800w\" sizes=\"auto, (max-width: 1168px) 100vw, 1168px\" \/><\/p>\n<p>Once done click on Actions button, click on Deploy API option.<\/p>\n<h4>Deployment<\/h4>\n<p>Select a new stage and deploy the API.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-141\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/44.jpg\" alt=\"\" width=\"471\" height=\"313\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/44.jpg 471w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/44-300x199.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/44-120x80.jpg 120w\" sizes=\"auto, (max-width: 471px) 100vw, 471px\" \/><\/p>\n<p>You can notice the newly created stage in the stages options. Select the newly created stage, select POST method and copy the invoke URL as highlighted below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-142\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/45.jpg\" alt=\"\" width=\"1181\" height=\"268\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/45.jpg 1181w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/45-300x68.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/45-768x174.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/45-1024x232.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/45-800x182.jpg 800w\" sizes=\"auto, (max-width: 1181px) 100vw, 1181px\" \/><\/p>\n<p>Copy the invoke URL that you see and you can use it directly to invoke the Lambda function via this stage and method of the API. Now open your browser paste invoke URL and add \u201c?number=20\u201d and press enter. (Note you can change this number to any integer value.)<\/p>\n<pre><a href=\"https:\/\/q2ydai5kg9.execute-api.us-east-2.amazonaws.com\/prod\/evenodd?number=20\">\u00a0<u>https:\/\/n79ttbsqyf.execute-api.us-east-2.amazonaws.com\/post\/evenodd<\/u>?number=20<\/a><\/pre>\n<p>*** replace above link with your link and use this endpoint. ***<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-143\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/46.jpg\" alt=\"\" width=\"852\" height=\"179\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/46.jpg 852w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/46-300x63.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/46-768x161.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/46-800x168.jpg 800w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/p>\n<p>Congratulations\u200a- \u200ayou have just set up and deployed your own Lambda Function &amp; API Gateway!<\/p>\n<h2>Deleting Resources<\/h2>\n<p>To delete these resources, follow below screenshots:<\/p>\n<h3>API Gateway<\/h3>\n<p>To delete the API, go back to the API Gateway page and select the API Gateway, then click on the actions button and select \u201cDelete API\u201d option.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-144\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/47.jpg\" alt=\"\" width=\"773\" height=\"379\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/47.jpg 773w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/47-300x147.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/47-768x377.jpg 768w\" sizes=\"auto, (max-width: 773px) 100vw, 773px\" \/><\/p>\n<p>Once you click on the Delete API you will get below pop up type the name of the API in the text box and then click delete API, make sure you type correct name otherwise you may delete any other resources.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-145\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/48.jpg\" alt=\"\" width=\"466\" height=\"201\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/48.jpg 466w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/48-300x129.jpg 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/p>\n<h3>Lambda Function<\/h3>\n<p>Similarly, to delete the Lambda function, go to Lambda console, and select the function to delete it.<\/p>\n<p>Click the delete button at the top, below pop up will follow:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-146\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/49.jpg\" alt=\"\" width=\"1305\" height=\"242\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/49.jpg 1305w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/49-300x56.jpg 300w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/49-768x142.jpg 768w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/49-1024x190.jpg 1024w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/49-800x148.jpg 800w\" sizes=\"auto, (max-width: 1305px) 100vw, 1305px\" \/><\/p>\n<p>Confirm delete by clicking on Delete, this way the function gets deleted.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-147\" src=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/50.jpg\" alt=\"\" width=\"468\" height=\"158\" srcset=\"https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/50.jpg 468w, https:\/\/www.ecomm.in\/blog\/wp-content\/uploads\/2017\/08\/50-300x101.jpg 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/p>\n<p>Congratulations you have successfully completed this simple AWS Lambda Function.<\/p>\n<p>If you have any questions related to this post or face any problems, then do comment and I will try to resolve them as quickly as possible.<\/p>\n<p>Thanks for reading!<\/p>\n<script>(function() {\n\twindow.mc4wp = window.mc4wp || {\n\t\tlisteners: [],\n\t\tforms: {\n\t\t\ton: function(evt, cb) {\n\t\t\t\twindow.mc4wp.listeners.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tevent   : evt,\n\t\t\t\t\t\tcallback: cb\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n})();\n<\/script><!-- Mailchimp for WordPress v4.10.4 - https:\/\/wordpress.org\/plugins\/mailchimp-for-wp\/ --><form id=\"mc4wp-form-1\" class=\"mc4wp-form mc4wp-form-26\" method=\"post\" data-id=\"26\" data-name=\"Blog\" ><div class=\"mc4wp-form-fields\"><p>\r\n  <h3>\r\n    Subscribe to our newsletter:\r\n  <\/h3>\r\n\r\n  <span>\r\n    <label>Name:<\/label>\r\n    <input type=\"text\" name=\"FNAME\" placeholder=\"Your Name\">    \r\n  \t\r\n    &nbsp;&nbsp;\r\n    \r\n\t<label>Email address: <\/label>\r\n\t<input type=\"email\" name=\"EMAIL\" placeholder=\"Your email address\" required \/>    \r\n \t\r\n    &nbsp;&nbsp;&nbsp;\r\n    \r\n\t<input type=\"submit\" value=\"Subscribe\" \/>    \r\n  <\/span>\r\n<\/p><\/div><label style=\"display: none !important;\">Leave this field empty if you're human: <input type=\"text\" name=\"_mc4wp_honeypot\" value=\"\" tabindex=\"-1\" autocomplete=\"off\" \/><\/label><input type=\"hidden\" name=\"_mc4wp_timestamp\" value=\"1776308461\" \/><input type=\"hidden\" name=\"_mc4wp_form_id\" value=\"26\" \/><input type=\"hidden\" name=\"_mc4wp_form_element_id\" value=\"mc4wp-form-1\" \/><div class=\"mc4wp-response\"><\/div><\/form><!-- \/ Mailchimp for WordPress Plugin -->\n","protected":false},"excerpt":{"rendered":"<p>Howdy techies! I&#8217;m Tanmay with the DevOps team at Ecomm India Cloud IT which helps companies with cloud transformation and<\/p>\n","protected":false},"author":4,"featured_media":161,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[13,15,10,16,18,17,11,12,14,9],"class_list":["post-94","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-api","tag-api-gateway","tag-aws","tag-deploy","tag-function","tag-integration","tag-lambda","tag-python","tag-restapi","tag-serverless"],"_links":{"self":[{"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/comments?post=94"}],"version-history":[{"count":9,"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/posts\/94\/revisions\/166"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/media\/161"}],"wp:attachment":[{"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/media?parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/categories?post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecomm.in\/blog\/wp-json\/wp\/v2\/tags?post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}