API Gateway Flashcards
What are the three main API Gateway Endpoint Types
Edge Optimized (default)
- Requests are routed through the CloudFront Edge locations
- API Gateway still only lives in one region
Regional
- For clients within the same region
- Could manually combine with CloudFront
Private
- Can only be accessed from you VPC using an interface VPC endpoint (ENI)
- Use resource polict to fedine access
What is an API deployment?
- A point-in-time snapshot of your API Gateway API.
- To be available for clients to use, the deployment must be associated with one or more API stages
What is an API stage?
A logical reference to a lifecycle state of your API (for example, ‘dev’, ‘prod’, ‘beta’, ‘v2’). API stages are identified by API ID and stage name.
What are Canary deployments on API Gateway?
- It the API Gateway verson of a blue/green deployment with AWS lambda.
- Choose the % of traffic the canary channel recieves
Why use an API cache? When would you not use one?
- Caching reduces the # of calls made to the backend.
- They are defined per stage
- Can be encrypted
- They are expensive so may not make sense in the dev environment.
How are API Gateway Caches invalidated?
- Clients can invalidate the cache with header: Cache-Control: max-age=0 (requires proper IAM authorization)
- If you do not impose an InvalidateCache policy (or choose the Require authorization check box in the console), any client can invalidate the API cache = bad.
What is the default TTL in the API Gateway Cache?
300 seconds (5 mintues)
min = 0s, max = 3600s
What are the 4 Integration Types for API Gateways?
- MOCK
- HTTP
- AWS_PROXY (Lambda Proxy)
- HTTP_PROXY
Describe API Gateway Integration Type MOCK
- API Gateway returns a response without sending the request to the backend.
- Good for development
Describe API Gateway Integration Type HTTP / AWS (Lambda and AWS Services)
- You must configure both the integration request and integration response
- Setup data mapping using mapping templates for the request and response
Describe API Gateway AWS_PROXY Integration Type
- Incoming request from the client is the input to Lambda
- The function is responsible for the logic of request / response
- No mapping template, headers, query string parameters etc. are passed as arguments.
Describe API Gateway HTTP_PROXY Integration Type
- No Mapping template
- The HTTP request is passed to the backend
- The HTTP repsonse from the backend is forwarded by API Gateway
What are API Gateway Mapping Templates?
- Mapping templates are data transformation tools that can be used to modify request / responses.
- Rename / Modify query string params
- Modify body content
- Add Headers
- Uses Velocity Template Language (VTL): for loop, if etc …
- Filter output results (remove unnecessary data)
In API Gateway, what is an integration?
- Integration connects a route to backend resources.
- Each API type has its own integration types.
What are the 4 API Gateway types? Summarize Each.
HTTP API
- Low latency and cost effective. Integrates in with OAuth and OIDC.
- Works with Lambda and HTTP backends
- No useage plan
REST API
- Have more control - main use of API Gateway
- Works with Lambda, HTTP, AWS Services
Web Socket API
- Best used for real-time data apps like chat applications or dashboards.Think 2-way applications.
- Requests get routed to a specific routing expression.
- Works with Lambda, HTTP, and AWS Sweater
REST API (Private)
- Accessible only from VPC