<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Muhammad Shakeel</title>
    <description>The latest articles on Forem by Muhammad Shakeel (@shakeel0581).</description>
    <link>https://forem.com/shakeel0581</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F885867%2F05d373c5-9e23-4971-9dbb-35ddc27d49e7.jpeg</url>
      <title>Forem: Muhammad Shakeel</title>
      <link>https://forem.com/shakeel0581</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shakeel0581"/>
    <language>en</language>
    <item>
      <title>AWS API Gateway Input/Output Mapping | Part 1</title>
      <dc:creator>Muhammad Shakeel</dc:creator>
      <pubDate>Thu, 04 Aug 2022 20:12:00 +0000</pubDate>
      <link>https://forem.com/shakeel0581/aws-api-gateway-inputoutput-mapping-part-1-4m7m</link>
      <guid>https://forem.com/shakeel0581/aws-api-gateway-inputoutput-mapping-part-1-4m7m</guid>
      <description>&lt;p&gt;I want to just create a really simple lambda function to demo how do I let's start by changing the output okay. I have already created lambda function. &lt;/p&gt;

&lt;h2&gt;
  
  
  Create Lambda function
&lt;/h2&gt;

&lt;p&gt;You use a Lambda function for the backend of your API. Lambda runs your code only when needed and scales automatically, from a few requests per day to thousands per second.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@m.shakeel0581/aws-appsync-graphql-apis-to-invoke-lambda-function-fc9b871e8d10" rel="noopener noreferrer"&gt;Lambda functions and Lambda layers See the full story before going on&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm going to create some JSON object that is my response and let's assume that my JSON object is some kind of student right so. I have an ID a name and email whatever other additional details I care about for a student okay so I'm going to say that there's an ID that'll be a numeric a name which will be some string an email an age weight that should be fine. so this is my response I build an object that has some key value pairs and save the lambda function.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

exports.handler = async (event) =&amp;gt; {
  const response = {
    "id": 1,
    "name": "joe bloN",
    "email": "m.shakeel0581@gmial.com",
    "age": 44,
    "weight": 258,
  }
  return response;
};



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here is code of lambda function, update the lambda function with above code and hit the deploy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzdzlll4h88cxow000c9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzdzlll4h88cxow000c9b.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect lambda function to an API gateway
&lt;/h2&gt;

&lt;p&gt;Now I want to connect this lambda function to an API gateway so that I can access this function over the Internet through an API so maybe I want to write a JavaScript application that's gonna connect to that URL okay. So in order to do, that I'm going to go over to API and I'm going to build out a RESTful API. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I already created and setup RESTful API in my previous story. &lt;a href="https://dev.to/shakeel0581/how-to-create-api-using-aws-api-gateway-service-amazon-api-gateway-serverless-3fnj"&gt;See the full story before going on&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So open 'sample-Api' from API Gateway that have created above mentioned story. so right now, we're not doing anything with this to reshape our data but I'm able to test this.&lt;br&gt;
Choose the method POST and go to Method Test page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiui0bm3kvmhf28gx133f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiui0bm3kvmhf28gx133f.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;okay so if I just click on test. I want to see what the return value. I can hit test there are no parameters and you'll notice if I test it, you can see that I get that student object that I created in lambda.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvaxc0amavrlchxxndut5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvaxc0amavrlchxxndut5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;okay so a couple of things about this pipeline. The top two boxes are for the request, as the request is coming in the method request I can do validation like did you pass in JSON web token for authorization or did you pass in an API key or if you're inserting a new record.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x9uv5j9qv32rtqvl21p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x9uv5j9qv32rtqvl21p.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the integration response and then the method response will have information about like your requests are your response headers if we're gonna enable cores which is cross-origin resource sharing so that we can access our API from remote domains.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ikra0zvoswrj6bjxxd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ikra0zvoswrj6bjxxd1.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
So all of those different filters or boxes are up for a reason.&lt;/p&gt;

&lt;h2&gt;
  
  
  Models
&lt;/h2&gt;

&lt;p&gt;API gateway there's a section called models alright. I have explained about modal in my last story. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://dev.tourl"&gt;You can find out modal section in this story here.&lt;/a&gt;&lt;br&gt;
I'm building out a restful api and I'm gonna have different HTTP verbs I might be getting students I might be inserting students I may be updating students I might be deleting students I need to know what a student actually looks like I know what a student looks like because I built it in lambda it has an ID a name and email and agent weight so that's what I wanted to find as a student object but then I want to clarify what a student object is I would argue that the ID is a number the name is a string the emails a string the age is a number and the weights a number okay so I want to be specific about what a student is I want to provide a definition saying these are the properties that compose a student and those properties are of these specific data types okay if I want to do hat I do that in models so I'm jumping over to model.&lt;br&gt;
I'm gonna create a model. My model is gonna be student and the content type is going to be application/JSON. The model name is required the content type is required the descriptions not required but I'm just putting in kind of a generic description and then I'm going to paste that schema definition that I had taken from Amazon ad just create the model.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

{
"$schema": "https://json-schema.org/draft-04/schema",
"title": "MATCDemoStudentOutputModel",
"type": "object",
    "properties": {
        "id": { "type": "number" },
        "name": { "type": "string" },
        "email": { "type": "string"},
        "age": { "type": "number" },
        "weight": { "type": "number" }
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ozh6j4c4i4hu5fpylut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ozh6j4c4i4hu5fpylut.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now I'm going to integrate model schema to the Integration Response.&lt;br&gt;
Select Integration Response from POST - Method Execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdp6ez5c5pkr75w6xo5c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdp6ez5c5pkr75w6xo5c.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm going into that mapping template and then click on Add mapping template. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famuxrmue4o9uc1w7quj5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famuxrmue4o9uc1w7quj5.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Add Content-Type application/json and click check icon to add.&lt;br&gt;
Now I can choose that model is student. So if I choose that model as my template it builds me dummy data it says here's the properties that I know about for a student this is what should be their data gives dummy data right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe5bljrbyvihwd27cmsm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe5bljrbyvihwd27cmsm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we don't make any changes I just say based on the model I have some dummy data if I save it right now and go back and I want to test this see if it's working. Remember I'm gonna make a request that's all done for me that's what the test does I end up at my lambda end point and before what was happening is as returning a student that looked like this this is what's defined in lambda this fake student now that I've defined my mapping template in my integration response. I said no that's not what the data is gonna look like I want to use some dummy data. I'm kind of ignoring the response from lambda right those values were hard-coded pi and foo for the name and email. So now if I test this, you'll notice that I get the data from the integration response that dummy data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzw0gqkaskn5yanp3tvm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzw0gqkaskn5yanp3tvm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;okay so we can get a little closer so if I go back into my mapping template let's assume that age and weight are sensitive right so we don't want to send that information. I'm just not going to include it in my template I know what the model was I know the model included agent weight I don't want people that are gonna use my API to see that information so I've changed my mapping template so now I save it .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9bdkap53xg8pohjorr9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9bdkap53xg8pohjorr9.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Now if I go back and I test it again now you'll notice the age and weight are removed it doesn't have the data that we want. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxicih0c3e4cbr39p83j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxicih0c3e4cbr39p83j.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
They'll right it has the hard-coded data for the ID and the name and the email like I probably want to get that information from my lambda function I just want to strip off the variables that I don't want my API consumers to see it's that fair.&lt;/p&gt;

&lt;p&gt;so this Joe Blow this is the data assuming that Joe Blow is an actual student but I want his age and weight stripped off okay so if I go back over to my integration response the way I'm going to get that is with that templating language okay so for the ID the way I'm gonna get the ID is I'm going to use my variable input root an input root is talking about the root element of my response so the root element of my JSON response so input root is really this object so I want the input root Dot ID and here I want the input root name and here I want the input root email okay so I'm saying from my response that I got back from lambda I have a variable called input root as which is referring to that root element that got returned and now I'm saying pick out the individual components so that I can build an object that looks like this &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr9u4ldhj06ex1w30hs5z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr9u4ldhj06ex1w30hs5z.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Okay now if I go back and I test it I intentionally okay here's the mapping template.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7ksn6hqcwdzngyj061f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7ksn6hqcwdzngyj061f.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
so I know that initially I started with a student that had an email maybe my client application expects it to be email address.&lt;br&gt;
let's assume that I don't want to return email to the end user I want to return an email address I can create a new property&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ik5zwpx1wshnrra8ysg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ik5zwpx1wshnrra8ysg.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Okay now I go back I test it you can see that my output is email address all of these changes are great I've built all of these changes in my API gateway.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqwsaua1h9jkv6yov1nle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqwsaua1h9jkv6yov1nle.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
if we want to reshape the data we're going to be under resources and then a specific method in the integration response is where we would reshape our data.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>apigateway</category>
      <category>serverless</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Explain AWS Cognito Authorizers Like I'm Five</title>
      <dc:creator>Muhammad Shakeel</dc:creator>
      <pubDate>Fri, 29 Jul 2022 18:55:28 +0000</pubDate>
      <link>https://forem.com/shakeel0581/explain-aws-cognito-authorizers-like-im-five-4od5</link>
      <guid>https://forem.com/shakeel0581/explain-aws-cognito-authorizers-like-im-five-4od5</guid>
      <description>&lt;p&gt;I am developing a react native mobile app. I want my user to login in one device with once account. If a  user tries to login to another mobile device with same account, he should be logout from the first mobile device. but official docs of AWS cognito provide two options either logout or global logout. In global logout it logs user out from device 1 and 2 both. what is expected If a user logs in second mobile device it should automatically be logout from the other one.&lt;/p&gt;

&lt;p&gt;Please see the attached SDK link.&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#globalSignOut-property"&gt;https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#globalSignOut-property &lt;/a&gt;&lt;br&gt;
SDK: &lt;a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#globalSignOut-property"&gt;https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#globalSignOut-property &lt;/a&gt;&lt;/p&gt;

</description>
      <category>cognito</category>
      <category>aws</category>
      <category>authentication</category>
    </item>
    <item>
      <title>How to validate request body | Amazon API Gateway</title>
      <dc:creator>Muhammad Shakeel</dc:creator>
      <pubDate>Wed, 27 Jul 2022 20:44:20 +0000</pubDate>
      <link>https://forem.com/shakeel0581/how-to-validate-request-body-amazon-api-gateway-2mpp</link>
      <guid>https://forem.com/shakeel0581/how-to-validate-request-body-amazon-api-gateway-2mpp</guid>
      <description>&lt;p&gt;this week I have learned about payload or body validation in AWS API Gateway and want to share it. Last week we learned how to create API using the AWS API Gateway service. &lt;a href="https://dev.to/shakeel0581/how-to-create-api-using-aws-api-gateway-service-amazon-api-gateway-serverless-3fnj"&gt;Here,  you can read about it&lt;/a&gt;&lt;br&gt;
In this session, we will learn about how to validate body or payload in the AWS API. we have already set up the API gateway and we just focus on API body validation, how can active body validation and how its works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview of basic request validation in API Gateway
&lt;/h2&gt;

&lt;p&gt;Request validation is used to ensure that the incoming request message is properly formatted and contains the proper attributes. API Gateway can perform the basic validation. This enables you, the API developer, to focus on app-specific deep validation in the backend. For the basic validation, API Gateway verifies either or both of the following conditions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The required request parameters in the URI, query string, and headers of an incoming request are included and non-blank.&lt;/li&gt;
&lt;li&gt;The applicable request payload adheres to the configured JSON schema request model of the method.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First, we need to create a model to set up JSON schema request. Before creating  model, we need to know about the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Models
&lt;/h2&gt;

&lt;p&gt;In API Gateway, a model defines the data structure of a payload. In API Gateway models are defined using the &lt;a href="https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-04" rel="noopener noreferrer"&gt;JSON schema draft 4&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The following JSON object describes sample data that describes the fruit or vegetable inventory in the produce department of a likely supermarket.&lt;/p&gt;

&lt;p&gt;Suppose we have an API for managing clothing inventory in the produce department of a supermarket. When a manager queries the backend for the current inventory, the server sends back the following response payload:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

{
  "department": "produce",
  "categories": [
    "jeans",
    "shirt"
  ],
  "dress": [
    {
      "category": "jeans",
      "type": "pants",
      "price": 1.99,
      "quantity": 232
    },
    {
      "category": "jeans",
      "type": "casual",
      "price": 0.19,
      "quantity": 112
    },
    {
      "category": "jeans",
      "type": "shorts",
      "price": 1.29,
      "quantity": 57
    }
  ]
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.html?icmpid=docs_apigateway_console#models-mappings-models" rel="noopener noreferrer"&gt;you can see detail about Models here &lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a model
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign in to the API Gateway console at &lt;a href="https://console.aws.amazon.com/apigateway" rel="noopener noreferrer"&gt;https://console.aws.amazon.com/apigateway&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose a REST API. In my case I will choose &lt;code&gt;sample-Api&lt;/code&gt;, that I have been created in last story. &lt;a href="https://dev.to/shakeel0581/how-to-create-api-using-aws-api-gateway-service-amazon-api-gateway-serverless-3fnj"&gt;see here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the Models tab from left and Choose Create.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd3kjtjgr4zgoddp2yxd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd3kjtjgr4zgoddp2yxd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;For Model Name, type name for the model 'item'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Content Type, type the model's content type (for example, application/json for JSON).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(Optional) For Model description, type a description for the model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Model schema, type the model's schema.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title":"Item Schema",
        "type": "object",
        "properties":{
            "ID":{ "type": "number"},
            "name":{ "type": "string"},
            "price":{ "type": "number"}
        },
        "required":["ID","name","price"]

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Choose Create model.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gomzh49lyxg0w4016j9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gomzh49lyxg0w4016j9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Request validation using the API Gateway console with model
&lt;/h2&gt;

&lt;p&gt;The API Gateway console lets you set up the basic request validation on a method using one of the three validators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validate body: This is the body-only validator.&lt;/li&gt;
&lt;li&gt;Validate query string parameters and headers: This is the parameters-only validator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Validate body, query string parameters, and headers: This validator is for both body and parameters validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To enable a request validator on a method&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose resource tab and then choose method the resource 'POST'.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6u4mlbr95tej9hjl7wr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6u4mlbr95tej9hjl7wr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose Method Request.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbis55v5hbhl6mmolpckm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbis55v5hbhl6mmolpckm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose the pencil icon of Request Validator under Settings.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6tbsb258cubdge4uyjzj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6tbsb258cubdge4uyjzj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose Validate body from drop down list. Then choose the check mark icon to save your choice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9cjb6qmlwnwbqwt7iwai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9cjb6qmlwnwbqwt7iwai.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose the Body Request and choose add model.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xbsaeaaaax52mmhi55p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xbsaeaaaax52mmhi55p.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now add Content type 'application/json' and Model name 'item' from drop down list under the Modle Name. Then choose the check mark icon to save your choice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folqi614le3q8gitpzpp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folqi614le3q8gitpzpp7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;last step to deploy the API to sample stage. Select Actions button and choose Deploy API.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr49yxbmcouw625yu6j7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr49yxbmcouw625yu6j7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A pop up appear, choose 'smapleStage' from Deployment stage drop down and Deploy.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa9vik6jzbq12q4dl9ul1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa9vik6jzbq12q4dl9ul1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work
&lt;/h2&gt;

&lt;p&gt;we need to check this out request body validation is working fine with the rest API. For this, we need to use the postman to generate the post request with the request body&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test REST API in postman to verify that body validation working file with rest API&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CHoose POST request, Set header 'Content-Type' with value 'application/json' and body&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdw00ty2za61wqb7ubdup.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdw00ty2za61wqb7ubdup.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set request body with dummy data and hit the send button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjc789mbacvlrszqx5pyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjc789mbacvlrszqx5pyn.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
you can see that our Lambda function invoked and its return response.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5df1wjd22lyo894bklp4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5df1wjd22lyo894bklp4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now change the body request and remove the any field and its value. Hite the send button. This time you can see its return error "Invalid request body".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6r8itrkoxhsi5vze0we5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6r8itrkoxhsi5vze0we5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>api</category>
      <category>aws</category>
      <category>apigatewa</category>
    </item>
    <item>
      <title>Explain Aws API Gateway vulnerabilities Like I'm Five</title>
      <dc:creator>Muhammad Shakeel</dc:creator>
      <pubDate>Sat, 23 Jul 2022 19:34:16 +0000</pubDate>
      <link>https://forem.com/shakeel0581/explain-aws-api-gateway-vulnerabilities-like-im-five-5ad0</link>
      <guid>https://forem.com/shakeel0581/explain-aws-api-gateway-vulnerabilities-like-im-five-5ad0</guid>
      <description>&lt;p&gt;I have used API gateway to build business logic for my app that invokes lambda function. For security assurance, I have generated a VAT report of the base URL of API from my cyber security expert. A total of 9 Vulnerabilities have been detected including Four Medium, three low-level, and two informational-level vulnerabilities have been identified.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;(CSP) Wild Card Directive&lt;/li&gt;
&lt;li&gt;Content Security Policy (CSP) Header Not Set&lt;/li&gt;
&lt;li&gt;Cross-Domain Misconfiguration&lt;/li&gt;
&lt;li&gt;Missing Anti-clickjacking Header&lt;/li&gt;
&lt;li&gt;Server Leaks Information via “X-Powered-By” HTTP Response Header Field(s)&lt;/li&gt;
&lt;li&gt;Timestamp Disclosure – Unix&lt;/li&gt;
&lt;li&gt;X-Content-Type-Options Header Missing&lt;/li&gt;
&lt;li&gt;Charset Mismatch&lt;/li&gt;
&lt;li&gt;Re-examine Cache Directives&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;how can remove these all Vulnerability ? is there a need to set or define custom headers? ( if yes then where and how I can do that, either be in API Gateway console or lambda script or in my client or app side code where this API Gateway base URL is invoking ) ?&lt;/p&gt;

</description>
      <category>api</category>
      <category>vulnerabilities</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to create API using AWS API Gateway service - Amazon API Gateway Serverless</title>
      <dc:creator>Muhammad Shakeel</dc:creator>
      <pubDate>Sun, 03 Jul 2022 13:09:12 +0000</pubDate>
      <link>https://forem.com/shakeel0581/how-to-create-api-using-aws-api-gateway-service-amazon-api-gateway-serverless-3fnj</link>
      <guid>https://forem.com/shakeel0581/how-to-create-api-using-aws-api-gateway-service-amazon-api-gateway-serverless-3fnj</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello everyone!&lt;/strong&gt;, this is Muhammad Shakeel, I'm going to write my First story on dev.to. so today I'm talking about AWS API Gateway. API Gateway are very useful and give us many advantages like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Efficient API development&lt;/li&gt;
&lt;li&gt;Performance at any scale&lt;/li&gt;
&lt;li&gt;Cost savings at scale&lt;/li&gt;
&lt;li&gt;Easy monitoring&lt;/li&gt;
&lt;li&gt;Flexible security controls&lt;/li&gt;
&lt;li&gt;RESTful API options&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/api-gateway/"&gt;You can read more about AWS API Gateway here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Get started with Amazon API Gateway for REST APIs&lt;/strong&gt;&lt;br&gt;
so we getting started exercise, you create a serverless API. Serverless APIs let you focus on your applications, instead of spending time provisioning and managing servers. Amazon API Gateway provide three types of APIs&lt;/p&gt;

&lt;h2&gt;
  
  
  API type
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;1. HTTP API&lt;/em&gt;&lt;br&gt;
HTTP APIs are designed with minimal features so that they can be offered at a lower price.The HTTP API provides an HTTP endpoint for your Lambda function. API Gateway routes requests to your Lambda function, and then returns the function's response to clients.&lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html"&gt;more about HTTP API&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2. WebSocket API&lt;/em&gt;&lt;br&gt;
WebSocket APIs maintain persistent connections with clients for full-duplex communication&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3. REST API&lt;/em&gt;&lt;br&gt;
A REST API in API Gateway is a collection of resources and methods that are integrated with backend HTTP endpoints, Lambda functions, or other AWS services. API Gateway REST APIs use a request/response model where a client sends a request to a service and the service responds back synchronously. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;4. REST API Private&lt;/em&gt;&lt;br&gt;
REST API that is only accessible from within a VPC.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup REST API
&lt;/h2&gt;

&lt;p&gt;I'm going to create REST APIs. API Gateway also supports HTTP APIs and WebSocket APIs, but an REST API is the best choice for this exercise. REST APIs support more features than HTTP APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create Lambda function&lt;/strong&gt;&lt;br&gt;
You use a Lambda function for the backend of your API. Lambda runs your code only when needed and scales automatically, from a few requests per day to thousands per second.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@m.shakeel0581/aws-appsync-graphql-apis-to-invoke-lambda-function-fc9b871e8d10"&gt;Lambda functions and Lambda layers See the full story before going on&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create REST API&lt;/strong&gt;&lt;br&gt;
An API endpoint can be &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Edge-optimized API&lt;/strong&gt; endpoints(best for geographically distributed clients. API requests are routed to the nearest CloudFront Point of Presence)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regional API endpoints&lt;/strong&gt; (intended for clients in the same region. When a client running on an EC2 instance calls an API in the same region, or when an API is intended to serve a small number of clients with high demands, a regional API reduces connection overhead)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private API endpoints&lt;/strong&gt;(API endpoint that can only be accessed from your Amazon Virtual Private Cloud (VPC) using an interface VPC endpoint)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The taking after endpoint sort changes are supported&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From edge-optimized to regional or private&lt;/li&gt;
&lt;li&gt;From regional to edge-optimized or private&lt;/li&gt;
&lt;li&gt;From private to regional&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But You cannot alter a private API into an edge-optimized API&lt;/p&gt;

&lt;p&gt;we are goin to create REST API with Edge-optimized API endpoints for the best performance.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign in to the API Gateway console at &lt;a href="https://console.aws.amazon.com/apigateway"&gt;Here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose create API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As you can see there are 4 types of APIs. From REST API, choose Build.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sqqUINhK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yesdyiswxe6gu724ydf7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sqqUINhK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yesdyiswxe6gu724ydf7.jpg" alt="Image description" width="568" height="395"&gt;&lt;/a&gt;&lt;br&gt;
You can see the new page is open, and there is some defaults options are selected. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the Settings portion write API name 'sample-Api', Description ( Optional, you can leave it empty ) and choose Endpoint type 'Regional' and Hit the save. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ogWJAPFH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4k8doh9u95te9rjxv3j.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ogWJAPFH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4k8doh9u95te9rjxv3j.jpg" alt="Image description" width="880" height="364"&gt;&lt;/a&gt;&lt;br&gt;
(You can also &lt;strong&gt;Clone from existing API&lt;/strong&gt; by choosing this option form the portion above the setting and Select API that you want to clone)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now we need to create and deploy the resource and method. In the Resources tab, click on Actions button and choose Create Method&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uVACLYwr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axyel07b9og982pgjfb1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uVACLYwr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axyel07b9og982pgjfb1.jpg" alt="Image description" width="880" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose choose method POST and click check Icon.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q4b1l5HT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sihg3cgrf8800s2tgdyf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q4b1l5HT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sihg3cgrf8800s2tgdyf.jpg" alt="Image description" width="412" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now we need to setup POST method. Choose Integration type &lt;strong&gt;Lambda Function&lt;/strong&gt; and in Lambda Function choose &lt;strong&gt;sample-function&lt;/strong&gt; by typing the input field. Press the save&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qv4XSWma--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qute8ld2awprr9dhksw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qv4XSWma--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qute8ld2awprr9dhksw.jpg" alt="Image description" width="880" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;a pop-up appear with name 'Add Permission to Lambda Function', click 'Ok' for add  to give API Gateway permission to invoke your Lambda function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Vn6Ow4R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p79lkeqdu3zlai5u00cl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Vn6Ow4R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p79lkeqdu3zlai5u00cl.jpg" alt="Image description" width="880" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you can see the 'smaple-function' Lambda function are attached.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ckZnMkfN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssxhdfuo05sfyj500uyq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ckZnMkfN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssxhdfuo05sfyj500uyq.jpg" alt="Image description" width="880" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now we need to Enable CORS. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"&gt;You can read about CORS here&lt;/a&gt;
Click Actions and choose 'Enable CORS'. There  are some defaults values are selected, don't need to change them and click Blue right Button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yv39qgRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wl9u2h7yzs9x8t7o8m6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yv39qgRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wl9u2h7yzs9x8t7o8m6.jpg" alt="Image description" width="880" height="309"&gt;&lt;/a&gt;&lt;br&gt;
A Confirm method changes pop-up appear, Click the blue button from pop-up. Its enable the CORS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bbf1LqM6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iudaj7yfwzla17rqi6zo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bbf1LqM6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iudaj7yfwzla17rqi6zo.jpg" alt="Image description" width="880" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;All steps has been done, We just need to be deploy out API to Stage. Click again Action button and choose 'Deploy API'  from API ACTION. A Deploy API pop-up appear, select [New Stage] from Deployment stage option. Type stage name 'sampelStage', Type Stage description (optional) and Deployment description (optional). Click blue button Deploy.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xc6WxIcZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/165okcna0aqkzrb50ggd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xc6WxIcZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/165okcna0aqkzrb50ggd.jpg" alt="Image description" width="851" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All step has done now we need to test our API. Copy the Invoke URL from Stages tab, that appear on top. you can also see that our created stage are shoeing in this page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5oCiJCsO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5l04sthr1dqvzfj5hv3z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5oCiJCsO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5l04sthr1dqvzfj5hv3z.jpg" alt="Image description" width="880" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work!?
&lt;/h2&gt;

&lt;p&gt;Once the Lambda function with REST API has been setup, The REST API from AWS API gateway could be invoked similar to how any other REST APIs are invoked with CURL, Postman.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lambda function latest code&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&lt;br&gt;
exports.handler = async (event) =&amp;gt; {&lt;br&gt;
  return {&lt;br&gt;
    "Status": 200,&lt;br&gt;
    "Message": "Helo From Sample Lambda"&lt;br&gt;
  };&lt;br&gt;
};&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test REST API in postman&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EaaKkNMS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9q15px7ajptvpa6uhiw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EaaKkNMS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9q15px7ajptvpa6uhiw.jpg" alt="Image description" width="880" height="383"&gt;&lt;/a&gt;&lt;br&gt;
as you can see, our REST API run successfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign in to the API Gateway console at &lt;a href="https://console.aws.amazon.com/apigateway"&gt;Here&lt;/a&gt;&lt;br&gt;
and choose API 'sample-Api' and click Actions, then choose Delete.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M79vlNcD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55zjsn16mxito3gp3drg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M79vlNcD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55zjsn16mxito3gp3drg.jpg" alt="Image description" width="880" height="231"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An Delete API pop-up appear, click delete from this pop-up.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xOuJpEQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6dqsnp8jqyxbwqy4ssor.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xOuJpEQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6dqsnp8jqyxbwqy4ssor.jpg" alt="Image description" width="769" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
