API Gateway Flashcards
Wath are API Gateway integrations at a high level?
- Lambda function: Easy way to expose REST API
- HTTP: Internal HTTP API on-prem, ALB
- AWS Service: Any AWS API, i.e. start a Step Function workflow
What are API Gateway endpoint types?
- Edge-Optimized (default)
- Regional
- Private
What is API Gateway Edge-Optimized endpoint type used for?
For global clients
o Requests are routed through the CloudFront Edge locations (improves latency)
o The API Gateway still lives in only one region
What is API Gateway Regional endpoint type used for?
o For clients within the same region
o Could manually combine with CloudFront (more control over the caching strategies and the distribution)
What is API Gateway Private endpoint type used for?
o Can only be accessed from your VPC using an interface VPC endpoint (ENI)
o Use a resource policy to define access
What are API Gateway Deployment Stages?
- Making changes in the API Gateway does not mean they’re effective
- You need to make a “deployment” for them to be in effect
- Changes are deployed to “Stages” (as many as you want)
- Use the naming you like for stages (dev, test, prod)
- Each stage has its own configuration parameters
- Stages can be rolled back as a history of deployments is kept
What are API Gateway stage variables?
- Stage variables are like environment variables for API Gateway
- Use them to change often changing configuration values
Where can be used API Gateway stage variables?
They can be used in:
o Lambda function ARN
o HTTP Endpoint
o Parameter mapping templates
What are API Gateway stage variables use cases?
o Configure HTTP endpoints your stages talk to (dev, test, prod…)
o Pass configuration parameters to AWS Lambda through mapping templates
Set an example of using a API Gateway stage variable in a Lambda function context
LAMBDA_FUNCTION:${stageVariables.STAGE_VAR}
What you need to do in CLI when you set your API Gateway in front of Lambda Function as a stage variable?
You need to run a command in your CLI to update your Lambda resource-based policy
Run that command for each defined N alias, this will create N resource-based policies, one per each alias.
Where are API Gateway configurations available?
at stage level
What possibility you have regarding API Gateway deployments?
Possibility to enable canary deployments for any stage (usually prod)
How does work API Gateway Canary deployment?
- Choose the % of traffic the canary channel receives
- This is blue / green deployment with AWS Lambda & API Gateway
- Possibility to override stage variables for canary
- Metrics & Logs are separate (for better monitoring)
What are 4 API Gateway integration types?
- Mock
- HTTP / AWS (Lambda & AWS Services)
- AWS Proxy (Lambda Proxy)
- HTTP Proxy
What is API Gateway Mock integration type?
API Gateway returns a response without sending the request to the backend
What is API Gateway HTTP / AWS integration type?
o you must configure both the integration request and integration response (modify requests and responses)
o Setup data mapping using mapping templates for the request & response
What is API Gateway AWS Proxy integration type?
o incoming request from the client is the input to Lambda
o The function is responsible for the logic of request / response
o No mapping template, headers, query string parameters… are passed as arguments
What is API Gateway HTTP Proxy integration type?
o No mapping template
o The HTTP request is passed to the backend
o The HTTP response from the backend is forwarded by API Gateway
What are API Gateway Mapping templates?
- Mapping templates can be used to modify request / responses
- Rename / Modify query string parameters
- Modify body content
- Add headers
- Filter output results (remove unnecessary data)
What language is used by API Gateway Mapping Templates?
Velocity Template Language VTL
What can you use to import / export API Gateway Rest APIs?
- Swagger
- OpenAPI
What are API Gateway Cache TTL range values?
Default TTL is 5 minutes (min: 0s, max: 1 hour)
Where do you define API Gateway cache?
at stage level, but it is possible to override cache settings (disable, enable, modify TTL, etc.…) per method
What is API Gateway cache range capacity?
0.5 GB - 237 GB
How much does API Gateway cache cost?
Cache is expensive, makes sense in production, may not make sense in dev / test