API Gateway Flashcards

(67 cards)

1
Q

Wath are API Gateway integrations at a high level?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are API Gateway endpoint types?

A
  • Edge-Optimized (default)
  • Regional
  • Private
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is API Gateway Edge-Optimized endpoint type used for?

A

For global clients
o Requests are routed through the CloudFront Edge locations (improves latency)
o The API Gateway still lives in only one region

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is API Gateway Regional endpoint type used for?

A

o For clients within the same region

o Could manually combine with CloudFront (more control over the caching strategies and the distribution)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is API Gateway Private endpoint type used for?

A

o Can only be accessed from your VPC using an interface VPC endpoint (ENI)
o Use a resource policy to define access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are API Gateway Deployment Stages?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are API Gateway stage variables?

A
  • Stage variables are like environment variables for API Gateway
  • Use them to change often changing configuration values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Where can be used API Gateway stage variables?

A

They can be used in:
o Lambda function ARN
o HTTP Endpoint
o Parameter mapping templates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are API Gateway stage variables use cases?

A

o Configure HTTP endpoints your stages talk to (dev, test, prod…)
o Pass configuration parameters to AWS Lambda through mapping templates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Set an example of using a API Gateway stage variable in a Lambda function context

A

LAMBDA_FUNCTION:${stageVariables.STAGE_VAR}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What you need to do in CLI when you set your API Gateway in front of Lambda Function as a stage variable?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Where are API Gateway configurations available?

A

at stage level

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What possibility you have regarding API Gateway deployments?

A

Possibility to enable canary deployments for any stage (usually prod)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does work API Gateway Canary deployment?

A
  • 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are 4 API Gateway integration types?

A
  • Mock
  • HTTP / AWS (Lambda & AWS Services)
  • AWS Proxy (Lambda Proxy)
  • HTTP Proxy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is API Gateway Mock integration type?

A

API Gateway returns a response without sending the request to the backend

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is API Gateway HTTP / AWS integration type?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is API Gateway AWS Proxy integration type?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is API Gateway HTTP Proxy integration type?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are API Gateway Mapping templates?

A
  • 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What language is used by API Gateway Mapping Templates?

A

Velocity Template Language VTL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What can you use to import / export API Gateway Rest APIs?

A
  • Swagger

- OpenAPI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are API Gateway Cache TTL range values?

A

Default TTL is 5 minutes (min: 0s, max: 1 hour)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Where do you define API Gateway cache?

A

at stage level, but it is possible to override cache settings (disable, enable, modify TTL, etc.…) per method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is API Gateway cache range capacity?
0.5 GB - 237 GB
26
How much does API Gateway cache cost?
Cache is expensive, makes sense in production, may not make sense in dev / test
27
It is API Gateway cache encrypted?
you have the option to encrypt it
28
How can API Gateway cache be invalidated?
Clients can invalidate the cache with header: Cache-Control: max-age=0 + proper IAM authorization
29
What can happen if you don't specify an API Gateway invalidation policy?
If you don't impose an InvalidateCache policy (or choose the Require authorization check box in the console), any client can invalidate the API cache which can result in a disaster
30
What option do you have if you want to expose your API (Gateway) as an offering to your customers?
You can define an Usage plan
31
What can you define in an API Gateway Usage plan?
o who can access one or more deployed API stages and methods o how much and how fast they can access them o configure throttling limits and quota limits that are enforced on individual client
32
What are API Gateway API Keys?
alphanumeric string values to distribute to your customers that you can use with usage plans to control access
33
What need to provide callers of an API Gateway that is using an Usage Plan?
Callers of the API must supply an assigned API key in the x-api-key header in requests to the API
34
What is used by API Gateway to log and trace?
CloudWatch Logs and X-Ray
35
At what level can you enable API Gateway logging?
at the stage level, can override settings on a per API basis (ERROR, DEBUG, INFO)
36
Can you use metrics in API Gateway?
CloudWatch Metrics are by stage, possibility to enable detailed metrics
37
What are 5 more important API Gateway metrics?
- CacheHitCount - CacheMissCount - Count - IntegrationLatency - Latency - 4XXError (client-side) & 5XXError (server-side)
38
What are CacheHitCount and CacheMissCount metrics in API Gateway?
efficiency of the cache, if CacheHitCount is big then it is efficient
39
What is Count metric in API Gateway?
The total number API requests in a given period.
40
What is Integration Latency metric in API Gateway?
The time between when API Gateway relays a request to the backend and when it receives a response from the backend.
41
What is Latency metric in API Gateway?
The time between when API Gateway receives a request from a client and when it returns a response to the client. The latency includes the integration latency and other API Gateway overhead.
42
What is API Gateway requests throttling quantity?
API Gateway throttles requests at 10000 requests per second across all API Soft limit that can be increased upon request Just like Lambda Concurrency, one API that is overloaded, if not limited, can cause the other APIs to be throttled
43
In case of API Gateway Throttling what error you get?
429 Too many requests (retriable)
44
What can you do to improve performance of API Gateway in terms of throttling?
* Can set Stage limit & Method limits to improve performance * Or you can define Usage Plans to throttle per customer
45
What means API Gateway 4xx and 5xx errors?
4xx means client errors and 5xx means server errors
46
What is API Gateway 400 error?
Bad Request
47
What is API Gateway 403 error?
Access denied, WAF filtered
48
What is API Gateway 502 error?
Bad Gateway Exception, usually for an incompatible output returned from a Lambda proxy integration backend and occasionally for out-of-order invocations due to heavy loads
49
What is API Gateway 503 error?
Service Unavailable Exception
50
What is API Gateway 504 error?
Integration Failure – ex Endpoint Request Timed-out Exception
51
What is API Gateway request timeout?
API Gateway requests timeout after 29 second maximum
52
What you need to enable in API Gateway when you receive requests from another domain?
CORS must be enabled when you receive API calls from another domain through the console
53
What must contain API Gateway to accept CORS requests?
You must create (assisted by API Gateway) an OPTION method which will be used by CORS containing these headers: 1. Access-Control-Allow-Methods 2. Access-Control-Allow-Headers 3. Access-Control-Allow-Origin
54
When will not your API Gateway CORS configuration work?
If you API Gateway is in front of a Lambda Proxy this approach will not work. Instead you need to return the Access-Control-Allow-Origin header from the Lambda itself
55
What methods can you use for security in API Gateway?
- IAM - Cognito User Pools - Custom Authorizer (Lambda Authorizer)
56
What is great for IAM security in API Gateway?
Great for users / roles already within your AWS account, + resource policy for cross account
57
What leverages API Gateway IAM security?
“Sig v4” capability where IAM credential are in headers: Good to provide access to external users
58
How can you allow cross account access in API Gateway?
using Resource Policies combined with IAM Security
59
How does API Gateway IAM security handle Authorization and Authentication?
both are handled by IAM
60
How does API Gateway Custom Authorizer handle Authorization and Authentication?
Authentication = External (up to you) and Authorization = Lambda function
61
How does API Gateway Cognito security handle Authorization and Authentication?
Cognito handles authentication, you must implement authorization in the backend
62
How is API Gateway integrated to Cognito User Pools?
* Cognito fully manages user lifecycle, token expires automatically * API gateway verifies identity automatically from AWS Cognito * No custom implementation required
63
How is API Gateway integrated to Custom Authorizers?
Great for third party Token-based authorizer (bearer token) – ex JWT (JSON Web Token) or Oauth Lambda must return an IAM policy for the user, result policy is cached Very flexible in terms of what IAM policy is returned
64
What are Api Gateway HTTP APIs?
more simple, low cost, Rest APIs are better
65
What feature is not present in API Gateway REST APIs?
Native OpenID Connect / OAuth 2.0
66
What is WebSocket?
1. Two-way interactive communication between a user’s browser and a server 2. Server can push information to the client 3. This enables stateful application use cases
67
What are use cases for API Gateway WebSocket APIs?
real-time applications such as chat applications, collaboration platforms, multiplayer games, and financial trading platforms. Works with AWS Services (Lambda, DynamoDB) or HTTP endpoints