Easy ReviewSAA-C03
Design Secure Architectures29

API Gateway

Route API requests, control access, publish releases, and diagnose backend failures.

Este conteúdo de estudo ainda não foi traduzido, então aparece em inglês. Ajude a traduzir

API Gateway connects client requests or WebSocket messages to backend services. These sections cover REST deployments, integrations, access controls and operations, plus HTTP API authorization and WebSocket routing.

API Gateway basics

Amazon API Gateway is a managed front door for APIs that call Lambda functions or other backends.

How it works

  1. Define the API and its routes.
  2. Connect each route to a backend such as Lambda.
  3. Clients call the API through API Gateway.

Exam cues

  • If the question says create or secure an API, think API Gateway.

Remember

  • REST, HTTP and WebSocket APIs.

Trap: API Gateway exposes APIs; it does not run the business logic, which lives in the backend.

Da documentação da AWS (2)
  • Amazon API Gateway creates, publishes, maintains, monitors and secures REST, HTTP and WebSocket APIs at any scale.
  • An API Gateway REST API can integrate directly with AWS services, for example as a proxy to Amazon Kinesis, without a Lambda function in between.

Deployments and stages

A REST API deploymentA fixed snapshot of a REST API configuration that a stage can expose to callers. is a fixed snapshot of the API configuration. A stageA named reference to a deployed API configuration that clients can invoke. is the named reference clients use to reach a deployment, allowing a release to be attached to a new or existing stage.

How it works

  1. Define the API resources, methodsAn HTTP operation on an API resource that defines how a client accesses it. and integrationsThe configuration that connects an API method to a backend endpoint., the connections to backend services.
  2. Create a deployment containing that configuration and associate it with a stage.
  3. After resource or integration changes, deploy the updated API to the stage. Updates to stage settings or usage plansA set of deployed API stages and request targets associated with client API keys. do not require redeployment.
  4. Use stage variables, per-stage key-value settings, to select a backend URL or Lambda version or aliasAn updatable named pointer to a Lambda function version.. A Lambda alias is an updatable pointer to a function version.
  5. Configure Lambda invoke permissions manually for stage-variable targets. The selected function must belong to the API’s account.
  6. Provision a stage cache and enable method caching to serve cached responses and reduce calls to the endpoint.
  7. Roll back an API snapshot by changing the stage’s active deployment to an earlier deployment. Configure an API Gateway account IAM roleAn identity that a user, application or service assumes to obtain a set of permissions. for CloudWatch Logs when enabling stage logging.
  8. Select request parameters as cache keysSelected request values used to distinguish entries in the response cache. when responses differ by those parameters.

Exam cues

  • If the question says a REST API integration edit is invisible to callers, think create and associate a new deployment, because the stage still references an earlier snapshot.
  • If the question says test and production should call different Lambda aliases, think stage variables plus explicit invoke permissions, because selecting a function does not grant permission to call it.
  • If the question says HTTP API changes publish automatically, think automatic deployments on that HTTP API stage, because that option releases changes without a manual deployment.
  • If the question says reduce repeated backend calls, think REST API stage caching, because cached responses can be served without calling the endpoint.
  • If an API Gateway deployment breaks production, think changing the active deployment back to an earlier snapshot.
  • If requests with different query values receive the same cached response, include the distinguishing parameter in the cache key.
  • If CloudFormation deploys a REST API before its methods exist, add deployment dependencies on the methods.

Remember

  • Resource changes need deployment; stage configuration changes do not.
  • Keep credentials out of stage variables.

Trap: A stage variableA key-value configuration setting used by an API stage and its integrations. containing a Lambda target does not create its invoke permission. Configure that permission on the selected target.

Publishing a REST API configuration
12API configurationDeploymentStage
  1. Create an immutable deployment from the API configuration.

  2. Associate the deployment with a new or existing stage for callers.

Da documentação da AWS (19)
  • A REST API Deployment is an immutable representation of an API.
  • A deployment must be associated with a stage before callers can invoke it.
  • A REST API deployment can be associated with a new or existing stage.
  • REST API resource, method, integration, authorizer and model updates require redeployment.
  • REST API stage configuration updates do not require redeployment.
  • REST API usage plan configuration updates do not require redeployment.
  • Stage variables are per-stage key-value configuration used to select backend URLs or pass integration settings.
  • Stage variables can substitute a Lambda function name, version or alias in an integration URI.
  • When a Lambda function name is supplied through a stage variable, its invoke permission must be configured manually.
  • Lambda functions referenced through stage variables must be in the same account as the API.
  • Stage variables are not intended to hold sensitive data such as credentials.
  • HTTP API stages can enable automatic deployments so API changes are released automatically.
  • A Lambda alias is an updatable pointer to a function version.
  • With a provisioned API Gateway REST API stage cache and method caching enabled, cached responses can be served instead of calling the endpoint, reducing calls.
  • A REST API stage can be pointed to an earlier deployment to roll back the API snapshot.
  • REST API cache keys can include request parameters such as headers, paths, or query strings; requests sharing the selected key can reuse a cached response.
  • CloudWatch Logs for a REST API stage requires an IAM role configured on the API Gateway account that permits API Gateway to write logs.
  • When a CloudFormation template creates a REST API, its methods and its deployment together, the deployment must depend on the methods.
  • Amazon API Gateway creates, publishes and secures REST, HTTP and WebSocket APIs and acts as a front door to backends such as Lambda functions, EC2 and web applications.

Authentication and API keys

API Gateway access controls decide who may invoke an API. AuthenticationThe process of establishing the identity making a request. checks a caller’s identity; authorizationThe decision about whether an identity may perform a requested action. checks which calls that identity may make. API keysA client identifier used to associate REST API requests with a usage plan. identify clients for usage measurement and throttlingLimiting the target rate of incoming API requests. targets.

How it works

  1. Choose an access mechanism for the API type and its callers.
  2. For a REST API using IAM, set AWS_IAM on the methodAn HTTP operation on an API resource that defines how a client accesses it.. Give the caller execute-api:Invoke and require a signed request.
  3. Use a Lambda authorizerA component that evaluates caller credentials or tokens to allow or deny API access. for custom access decisions or a Cognito user pool authorizer for REST API users. HTTP APIs also support JWTA signed token containing claims that an HTTP API authorizer can validate. authorizers, which validate a JSON Web Token, a signed token containing identity claimsA value inside a token that describes its issuer, audience, validity or other identity information..
  4. Separately associate client API keys and deployed stages with a usage planA set of deployed API stages and request targets associated with client API keys. when you need per-client request targets and quotasA target request allowance over a time interval or another documented service limit..
Control API type Purpose
IAM REST and HTTP Authorize calls with AWS identities
Lambda authorizer REST and HTTP Run custom access logic
Cognito user pool authorizer REST Control access for user pool users
JWT authorizer HTTP Validate tokens and configured route scopes
API key and usage plan REST Identify clients and apply request targets

Exam cues

  • If the question says an AWS workload should invoke an API with its roleAn identity that a user, application or service assumes to obtain a set of permissions. credentials, think IAM authorization and signed requests, because invocation permission belongs to the caller’s AWS identity.
  • If the question says an HTTP API must accept identity-provider tokens and require a permission scopeA token permission value that an HTTP API route can require for access., think a JWT authorizer with route scopes, because token validation and scope checks happen before integrationThe configuration that connects an API method to a backend endpoint..
  • If the question says measure usage per customer, think API keys and usage plans, because a key identifies the client’s traffic across stages in that plan.

Remember

  • REST IAM calls support SigV4An AWS request signing protocol that API Gateway can use to authenticate caller credentials. and SigV4aAn AWS request signing protocol supported for IAM authentication of REST API callers. signatures. SigV4a support was added in August 2025.
  • A JWT route with scopes requires at least one matching token scope.
  • A key belongs to at most one usage plan for a given stageA named reference to a deployed API configuration that clients can invoke..
  • Usage plan quotas are best effort and can be exceeded.

Trap: An API key is not proof of caller identity. It also does not create a hard spending cap or guaranteed request ceiling.

Da documentação da AWS (19)
  • A REST API method configured with AWS_IAM requires IAM-authorized signed requests.
  • REST API IAM authentication supports SigV4 and SigV4a.
  • execute-api:Invoke permits calling deployed API methods.
  • API management permissions are separate from API invocation permissions.
  • REST API Lambda authorizers use a function to decide access from bearer tokens or request information.
  • REST APIs can use Amazon Cognito user pool authorizers to control invocation access.
  • REST API resource policies can allow or deny access based on source IP addresses or VPC endpoints.
  • HTTP APIs support IAM, Lambda authorizers and JWT authorizers.
  • An HTTP API JWT authorizer validates token signatures and claims including issuer, audience and expiration.
  • A token must contain at least one configured HTTP API route scope.
  • API keys identify clients for REST API usage plans.
  • API keys must not be used as API authentication or authorization.
  • A usage plan associates API stages and client API keys with request throttling targets and quotas.
  • Usage plan throttles and quotas aggregate each key across API stages in the plan.
  • An API key can belong to only one usage plan for a given API stage.
  • Usage plan throttles and quotas are best-effort targets that clients can exceed; do not rely on them to control costs or block access.
  • Authentication establishes the identity making a request.
  • Authorization determines whether an identity may perform the requested action.
  • API Gateway added SigV4a support for REST APIs in August 2025.

Endpoint types and throttling

API Gateway endpoint type decides where requests enter AWS, and throttlingLimiting the target rate of incoming API requests. decides how many get through.

How it works

  1. Choose an endpoint type per REST API: edge-optimized, Regional or private.
  2. Every request takes a token from a bucket that refills at the allowed rate.
  3. Limits apply from narrowest to widest: usage planA set of deployed API stages and request targets associated with client API keys. per client or methodAn HTTP operation on an API resource that defines how a client accesses it., stageA named reference to a deployed API configuration that clients can invoke. method limits, account per Region, then AWS Regional limits.
  4. When the bucket is empty, API Gateway answers 429 Too Many Requests.
Endpoint type Reach Fits
Edge-optimized (REST default) Nearest CloudFront point of presenceA CloudFront entry location through which an edge-optimized API can receive client requests. Clients around the world
Regional Same Region Same-Region clients, your own CloudFront, multi-Region with Route 53
Private Interface VPC endpointA network interface inside a VPC that provides private access to an AWS service. only Internal APIs

Exam cues

  • If the question says global clients, think edge-optimized; same-Region or multi-Region with latency routing, think Regional.
  • If the question says API reachable only from a VPC, think a private API.
  • If the question says 429 errors or protect the backend from burstsThe capacity of the request token bucket used to absorb a short traffic spike., think throttling settings, usage plans and caching.

Remember

  • Default account quotaA target request allowance over a time interval or another documented service limit.: 10,000 requests per second, burst 5,000, per Region, shared by all APIs.
  • Throttle order: usage plan, stage method, account, AWS Regional.
  • 429 means throttled; retry with backoff.

Trap: The account quota is shared by every API in the Region. Without stage or usage plan limits, one busy API can throttle all the others.

Da documentação da AWS (9)
  • An edge-optimized API Gateway endpoint routes requests through the nearest CloudFront point of presence, helps geographically distributed clients, and is the default endpoint type for REST APIs.
  • A Regional API Gateway endpoint is meant for clients in the same Region, such as EC2 callers, and can sit behind your own CloudFront distribution or use Route 53 latency routing across Regions.
  • A private API Gateway endpoint is reachable only from your VPC through an interface VPC endpoint.
  • API Gateway throttles with a token bucket per account and Region; requests beyond the rate and burst limits get 429 Too Many Requests, and clients should retry with backoff.
  • The default API Gateway throttle quota is 10,000 requests per second per account per Region across HTTP, REST and WebSocket APIs, with a burst bucket of 5,000 requests, and the rate can be raised on request.
  • API Gateway applies throttles in this order, per-client or per-method limits in a usage plan, per-method limits on the stage, the account limit per Region, then AWS Regional throttling.
  • REST and HTTP APIs in API Gateway give stateless client-server communication, while WebSocket APIs give stateful, full-duplex communication between client and server.
  • REST API stage caching returns cached endpoint responses for a TTL that defaults to 300 seconds and can be at most 3,600 seconds; a TTL of 0 turns caching off, and methods can override the stage setting.
  • AWS AppSync provides serverless GraphQL and Pub/Sub APIs that read from one or more data sources, such as DynamoDB, through a single GraphQL endpoint; pipeline resolvers run several functions in sequence to resolve one field.

Integrations and monitoring

An integrationThe configuration that connects an API method to a backend endpoint. connects an API methodAn HTTP operation on an API resource that defines how a client accesses it. to its backend. The integration type decides how much mapping you configure.

How it works

  1. A client calls a method. If request validation is on, API Gateway rejects an invalid request with 400 before going further.
  2. The integration request sends the call to the backend: as is for proxy types, or through mapping templates for AWS and HTTP custom types.
  3. The backend has up to the integration timeoutThe configured time API Gateway waits for an integration response before reporting a timeout. to answer (29 seconds by default).
  4. API Gateway returns the response. With HTTP API CORS configured, it also answers preflight OPTIONS requests automatically.
Integration type Backend Mappings
AWS_PROXY Lambda function None
AWS AWS service action, or Lambda custom Request and response
HTTP_PROXY HTTP endpoint None
HTTP HTTP endpoint Request and response

Exam cues

  • If the question says call Lambda with the least configuration, think Lambda proxy integrationAn integration that forwards request information to a backend under a defined input and output contract..
  • If the question says reject bad input before it reaches the backend, think request validation.
  • If a browser fails an HTTP API preflight request, configure CORS so API Gateway answers OPTIONS requests automatically.

Remember

  • Integration timeout: 50 ms to 29 seconds; raise it only for Regional or private APIs.
  • A Lambda proxy response in the wrong format returns 502 Bad Gateway.

Trap: Regional and private APIs can request a higher integration timeout quotaA target request allowance over a time interval or another documented service limit., but edge-optimized APIs cannot.

Da documentação da AWS (7)
  • REST API integration types are AWS (an AWS service action with mapped request and response), AWS_PROXY (Lambda proxy), HTTP (custom HTTP with mappings), HTTP_PROXY and MOCK.
  • With Lambda proxy integration (AWS_PROXY) you don't configure the integration request or response; API Gateway passes the client request to the function, and AWS recommends it for calling Lambda.
  • Lambda custom and HTTP custom integrations need mapping templates for the integration request and response, but let you reuse those mappings across backends with similar formats.
  • REST API request validation checks a request before the integration request; on failure API Gateway returns 400 to the caller and logs the result in CloudWatch Logs, which saves backend calls.
  • The integration timeout is 50 milliseconds to 29 seconds for every integration type; Regional and private APIs can request a higher quota, edge-optimized APIs can't.
  • When CORS is configured on an HTTP API, API Gateway answers preflight OPTIONS requests automatically, even without an OPTIONS route.
  • If a Lambda proxy integration returns output in a format other than the expected statusCode, headers and body structure, API Gateway returns 502 Bad Gateway.

Flashcards

toque para virar
Resposta

·

Todos os 29 flashcards em lista

A team needs a managed front door for a REST API backed by Lambda functions. Which service fits?

Amazon API Gateway.

Can Amazon API Gateway send requests straight to Amazon Kinesis without a Lambda function?

Yes. A REST API can use an AWS service integration as a Kinesis proxy.

When does a changed API Gateway REST API integration take effect for callers of an existing stage?

After creating a deployment containing the change and associating it with the stage. Stage settings themselves can be updated without redeploying the API.

An API Gateway REST API must call different Lambda aliases for test and production. How can the stages select their backends?

Use a stage variable in the integration URI for the Lambda alias. Configure invoke permission manually for each selected target; the function must be in the API's account.

An API Gateway REST API receives repeated requests and the team wants fewer calls to its backend. Which stage feature can help?

Provision a stage cache and enable method caching. API Gateway can serve cached responses instead of calling the endpoint.

A newly deployed API Gateway REST API breaks production. How can the team restore the prior API snapshot?

Change the stage's active deployment to an earlier deployment.

An API Gateway REST API serves the wrong cached response for requests with different query values. What should the team configure?

Include the relevant query parameter in the cache key so different values are cached separately.

An API Gateway REST API stage has CloudWatch logging enabled but cannot write logs. Which account setting should the team check?

Configure an IAM role on the API Gateway account that permits API Gateway to write to CloudWatch Logs.

A CloudFormation stack creates an API Gateway REST API, methods and a deployment together but deploys before the methods exist. How should the template be fixed?

Add a DependsOn dependency from the deployment to the methods.

A team wants a managed front door for a REST API whose backend is AWS Lambda. Which service fits?

Amazon API Gateway.

Which API Gateway features authenticate or authorize callers, and what do API keys do?

REST APIs support IAM signed requests, Lambda authorizers and Cognito user pool authorizers. HTTP APIs also support JWT authorizers. API keys identify usage-plan clients; they do not authenticate or authorize callers.

An AWS workload must invoke an API Gateway REST API using its IAM identity. What should the method and caller use?

Set the method authorization to AWS_IAM, grant execute-api:Invoke and sign requests using a supported AWS signature version.

A team protects an API Gateway REST API only with API keys and wants strong caller identity checks. What should it add?

An IAM, Lambda or Cognito authorizer suited to the clients. API keys serve usage plans and do not establish caller identity.

An API Gateway HTTP API accepts tokens from an identity provider and requires route permissions. Which control fits?

A JWT authorizer with the expected issuer and audience, plus route authorization scopes. The token must contain at least one configured route scope.

A team needs per-client request throttling for an API Gateway REST API. What should it use, and is the limit guaranteed?

Use an API key and usage plan with a throttling target. The target is best effort and can be exceeded.

A REST API serves mobile users worldwide from one Region. Which API Gateway endpoint type reduces their latency with no extra setup?

Edge-optimized (the default for REST APIs): requests enter at the nearest CloudFront point of presence.

An internal API must be callable only from inside a VPC, never from the internet. Which API Gateway endpoint type fits?

A private API, reached through an interface VPC endpoint.

An API deployed in two Regions must send each user to the closest Region under one custom domain. Which endpoint type and DNS feature fit?

Regional endpoints in each Region with the same custom domain, and Route 53 latency-based routing.

Clients of an API Gateway API start getting HTTP 429 during a traffic spike. What does that mean and what should clients do?

Throttling: requests exceeded the rate or burst limit.

Retry with exponential backoff; raise limits or add caching if the load is expected.

What is the default API Gateway request rate quota per account and Region?

10,000 requests per second with a burst of 5,000, shared by all APIs in the account and Region (increase on request).

One noisy API in an account consumes all of the Region's API Gateway throughput and starves other APIs. What limits it?

Set stage or method throttling (or usage plan limits per client) on that API, below the account-level quota.

Which API Gateway API type keeps a stateful, two-way connection between client and server?

A WebSocket API. REST and HTTP APIs are stateless request-response APIs.

A read-heavy REST API behind Lambda and Aurora serves data that changes rarely. What cuts backend load with the least change?

Turn on API Gateway stage caching. Responses are served from the cache for the TTL, which defaults to 300 seconds and goes up to 3,600 seconds.

A mobile app needs a serverless GraphQL API that reads and writes several DynamoDB tables. Which service fits better than API Gateway?

AWS AppSync, a managed GraphQL service; pipeline resolvers can combine operations on several tables for one field.

Which REST API integration type should you use to call a Lambda function with the least setup?

Lambda proxy integration (AWS_PROXY). API Gateway passes the whole request to the function, with no integration request or response mappings to configure.

A REST API backend keeps receiving malformed requests. How can API Gateway stop them before they reach the integration?

Turn on request validation for the method. Invalid requests get a 400 response and never reach the backend.

A Lambda function behind a Regional REST API needs 45 seconds. Does the default integration timeout allow it?

No. The default maximum is 29 seconds. A Regional or private API can request a higher integration timeout quota; an edge-optimized API can't, so long jobs usually move to an asynchronous pattern.

A browser app on another origin calls an API Gateway HTTP API and fails on the preflight request. What fixes it?

Configure CORS on the HTTP API. API Gateway then answers preflight OPTIONS requests automatically and adds the CORS headers.

An Amazon API Gateway REST API with a Lambda proxy integration returns 502 Bad Gateway although the function runs without error. What is a likely cause?

The function's response is not in the proxy format (statusCode, headers, body), so API Gateway rejects it.

Você concluiu todos os tópicos da SAA-C03!

Seu badge ficou dourado. Próximo passo: agendar a prova na AWS. Depois de passar, adicione-se ao Quem passou.

Compartilhar

Conte que você concluiu esta certificação

Concluí todos os tópicos da AWS Certified Solutions Architect - Associate (SAA-C03) no Easy Review. Venha estudar também!