API Gateway Flashcards
What is API Gateway?
Amazon API Gateway is a fully managed service that makes it easy for developers to publish, maintain, monitor, and secure APIs at any scale. With a few clicks in the AWS Management Console, you can create an API that acts as a “front door” for applications to access data, business logic, or functionality from your back-end services, such as applications running on Amazon Elastic Compute Cloud (Amazon EC2), code running on AWS Lambda, or any web application.
API gateway architecture
User makes a request through API gateway, which triggers a Lambda function or routes request to EC2 instances. That request is then cached at API gateway, so subsequent requests would return the cached endpoint
What is API caching?
Can enable API caching to cache your endpoint’s response. with caching, you can reduce the number of calls made to your endpoint and also improve the latency of the requests to your API. when you enable caching for a stage, API gateway caches responses from your endpoint for a specified TTL period in seconds. API gateway then responds to the request by looking up the endpoint from the cache instead of making a request to your endpoint
What can API gateway do?
Low cost and efficient, scales effortlessly (w/o autoscaling groups or EC2 servers but can cause security concerns), you can throttle requests to prevent attacks, connect to CloudWatch to log requests
Same origin policy
In computing, the same-origin policy is an important concept in the web app security model. Under the policy, a web browser permits scripts contained in a first web page to access data in a second web page, but only if both web pages have the same origin/domain name
Cross-Origin Resource Sharing (CORS)
CORS is one way the server at the other end (not the client) can relax the same-origin policy.
It is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside of the domain from which the first resource was served
Error: “Origin policy cannot be read at the remote resource”
You need to enable CORS on API gateway
T/F: API gateway has caching capabilities to increase performance
True
T/F: API gateway is low cost and scales automatically.
True
If you are using Javascript/AJAX that uses multiple domains with API gateway,
ensure you have enabled CORS on API Gateway