Allowing access to AWS API gateway via whitelist or an IP address.

2022.03.10

API

It stands for Application Program interface which helps in connection of two applications, computers, or between computer programs to talk to each other. It is used to access data, server software, or other applications and has been around for some time. Each time anyone uses a particular app for weather updates or good restaurants API’s is used.

API Gateway

A fully managed service that makes developers easily create, publish, maintain, monitor, and secure APIs at any scale. Using API Gateway can create Restful APIs and WebSocket APIs which have real-time two-way communication applications. It is a front door for applications to access data, business logic, or functionality from your backend services.

AWS Lambda

A Serverless compute service that runs code as a reply to events and automatically takes care of the bottom resources. It runs code on high availability compute infrastructure and performs all the administration of the compute resources. A few examples are HTTP requests vis Amazon API Gateway, changes to objects in S3, and many others.

Demo

Go to Lambda console and create the below function Now creating the API Gateway Creating source and method for the API Gateway Now deploying the API by following the below steps Copying the invoke URl pasting in new tab you will get not authorised by adding the resource "/ipl" you'll be able to access the lambda Now adding the following the resource policy in the resource policy section, which allows only the below IP address to access gateway when compared to before where anyone can access Again deploy API so as the changes are reflected Now when trying to access the link even with "/ipl" it rejects it Updating the IP address in resource policy with my system IP address Now deploying the API as done before, pasting invoke URL in new tab with "/ipl" and now we'll be able to access it