Skip to content

6. Create an API in AWS API Gateway

Vikas Rathod edited this page Feb 21, 2021 · 2 revisions

Create an API to talk to your Lambda function through API Calls

Follow below steps to Create a an API

  • Login into your AWS Management Console.
  • Make sure your in Canada (Central) ca-central-1 region
  • Go to Services , and open API Gateway under Networking & Content Delivery section.
  • Go to REST API and Click on Build
    • Select New API radio button.
    • Enter postAPI as API name (You can give any name)
    • Make sure your Endpoint Type is regional
    • Click on Create API
  • Now Click on Actions and select Create a Resource
    • Keep Configure as proxy reosource as Unchecked.
    • Enter postdata as Resource name
    • Check on Enable API Gateway CORS and click on Create Resource.
    • Select OPTIONS method from newly appeared option under postdata resource.
    • Click on Integration request.
    • Now keep Lambda Function as integration type
    • Mark as checked to Use Lambda Proxy integration option.
    • Keep Lambda region as ca-central-1
    • Enter postDynamo as Lambda Function
    • Click on Save

    If you've gave any different name while creating a Lambda function then you should give that specific name

    • Click OK on appeared INFO popup.
  • Now you've created a API to do communication with you Lambda function. But we still need to deploy it. So
    • To deploy this API click on Actions and select Deploy API
    • Go to Deployment Stage and select [New Stage].
    • Enter production as a stage name.
    • Feel free to add stage description and deployment description of your choice.
    • Click on Deploy.
  • Now you've deployed the API in production stage.
    • To integrate it with our use-case we need Invoke URL of specific Resource which is postdata in our case.
    • So Click on drop down symbol beside production stage.
    • Select OPTIONS method and look for Invoke URL.

MOST IMP: Now copy your Invoke URL and paste it in Notes.

You've successfully created and deployed an API.