API Gateway Flashcards

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
Q

What is API Gateway cache range capacity?

A

0.5 GB - 237 GB

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

How much does API Gateway cache cost?

A

Cache is expensive, makes sense in production, may not make sense in dev / test

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

It is API Gateway cache encrypted?

A

you have the option to encrypt it

28
Q

How can API Gateway cache be invalidated?

A

Clients can invalidate the cache with header: Cache-Control: max-age=0 + proper IAM authorization

29
Q

What can happen if you don’t specify an API Gateway invalidation policy?

A

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
Q

What option do you have if you want to expose your API (Gateway) as an offering to your customers?

A

You can define an Usage plan

31
Q

What can you define in an API Gateway Usage plan?

A

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
Q

What are API Gateway API Keys?

A

alphanumeric string values to distribute to your customers that you can use with usage plans to control access

33
Q

What need to provide callers of an API Gateway that is using an Usage Plan?

A

Callers of the API must supply an assigned API key in the x-api-key header in requests to the API

34
Q

What is used by API Gateway to log and trace?

A

CloudWatch Logs and X-Ray

35
Q

At what level can you enable API Gateway logging?

A

at the stage level, can override settings on a per API basis (ERROR, DEBUG, INFO)

36
Q

Can you use metrics in API Gateway?

A

CloudWatch Metrics are by stage, possibility to enable detailed metrics

37
Q

What are 5 more important API Gateway metrics?

A
  • CacheHitCount
  • CacheMissCount
  • Count
  • IntegrationLatency
  • Latency
  • 4XXError (client-side) & 5XXError (server-side)
38
Q

What are CacheHitCount and CacheMissCount metrics in API Gateway?

A

efficiency of the cache, if CacheHitCount is big then it is efficient

39
Q

What is Count metric in API Gateway?

A

The total number API requests in a given period.

40
Q

What is Integration Latency metric in API Gateway?

A

The time between when API Gateway relays a request to the backend and when it receives a response from the backend.

41
Q

What is Latency metric in API Gateway?

A

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
Q

What is API Gateway requests throttling quantity?

A

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
Q

In case of API Gateway Throttling what error you get?

A

429 Too many requests (retriable)

44
Q

What can you do to improve performance of API Gateway in terms of throttling?

A
  • Can set Stage limit & Method limits to improve performance
  • Or you can define Usage Plans to throttle per customer
45
Q

What means API Gateway 4xx and 5xx errors?

A

4xx means client errors and 5xx means server errors

46
Q

What is API Gateway 400 error?

A

Bad Request

47
Q

What is API Gateway 403 error?

A

Access denied, WAF filtered

48
Q

What is API Gateway 502 error?

A

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
Q

What is API Gateway 503 error?

A

Service Unavailable Exception

50
Q

What is API Gateway 504 error?

A

Integration Failure – ex Endpoint Request Timed-out Exception

51
Q

What is API Gateway request timeout?

A

API Gateway requests timeout after 29 second maximum

52
Q

What you need to enable in API Gateway when you receive requests from another domain?

A

CORS must be enabled when you receive API calls from another domain through the console

53
Q

What must contain API Gateway to accept CORS requests?

A

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
Q

When will not your API Gateway CORS configuration work?

A

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
Q

What methods can you use for security in API Gateway?

A
  • IAM
  • Cognito User Pools
  • Custom Authorizer (Lambda Authorizer)
56
Q

What is great for IAM security in API Gateway?

A

Great for users / roles already within your AWS account, + resource policy for cross account

57
Q

What leverages API Gateway IAM security?

A

“Sig v4” capability where IAM credential are in headers: Good to provide access to external users

58
Q

How can you allow cross account access in API Gateway?

A

using Resource Policies combined with IAM Security

59
Q

How does API Gateway IAM security handle Authorization and Authentication?

A

both are handled by IAM

60
Q

How does API Gateway Custom Authorizer handle Authorization and Authentication?

A

Authentication = External (up to you) and Authorization = Lambda function

61
Q

How does API Gateway Cognito security handle Authorization and Authentication?

A

Cognito handles authentication, you must implement authorization in the backend

62
Q

How is API Gateway integrated to Cognito User Pools?

A
  • Cognito fully manages user lifecycle, token expires automatically
  • API gateway verifies identity automatically from AWS Cognito
  • No custom implementation required
63
Q

How is API Gateway integrated to Custom Authorizers?

A

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
Q

What are Api Gateway HTTP APIs?

A

more simple, low cost, Rest APIs are better

65
Q

What feature is not present in API Gateway REST APIs?

A

Native OpenID Connect / OAuth 2.0

66
Q

What is WebSocket?

A
  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
Q

What are use cases for API Gateway WebSocket APIs?

A

real-time applications such as chat applications, collaboration platforms, multiplayer games, and financial trading platforms.
Works with AWS Services (Lambda, DynamoDB) or HTTP endpoints