Basics
Basics
- Create & Manage APIs
- Endpoint for applications
- Highly available, scalable, handles authentication & authorisation, throttling, caching, CORS, transformations, documentation with OpenAPI, direct integration etc.
- Public service
- Can provide HTTP, Rest or Web Sockets end points
- End point types are
- Edge Optimized - Incoming requested to nearest CloudFront Point of Presence (POP)
- Regional Endpoints - Clients from same region can connect
- Private Endpoints - Accessible only within a VPC through interface endpoint
- Stages can be used to host different version of the API or to host different environments.
- Stages can be used for canary deployments. Traffic can be distributed between a main and a canary stage
- Stage variables can take different values in each Stage
- APIGateway can import or export Swagger/Open API definition files
Error Codes
- 4XX Series - Client Error Codes. Something was done wrong by client
- 400 - Generic Bad Request
- 403 - Access Denied by Authorizer or WAF filtered the request
- 429 - API Gateway throttle
- 5XX Series - Server side error codes. Request was correct but something went wrong on server
- 502 - Bad gateway exception. Bad response from Lambda or the service
- 503 - Service is offline
- 504 - Integration Failure / Timeout of 29s
Caching
- Caching configured at stage level
- Cache on a stage can b 500MB to 237GB in size
- Cache TTL is configurable from min 0 to 3600seconds. Defaul value is 300 seconds
- Cache can be configured to be encrypted
Integrations
- Integrations are the backend services that API Gateway exposes as APIs
- Integrations can be Http Endpoints, Lambda, AWS services like DynamoDB, SNS, SQS, Step Functions
- The Request phase does Authorization, Validation & Transformation
- The Response phase does Tranformation, Preparation & Return
- Proxying does not involve any kind of Transformation. It means straight passthrough of data through API Gateway
- Types of Integrations include
- Mocks-Allows API Gateway to return a response itself without invoking any backend service
- HTTP - Exposes HTTP End Point. Also known as custom HTTP integration
- HTTP Proxy - Same as HTTP but no transformation is involved
- AWS - API exposes AWS Services
- AWS_PROXY(Lambda) - Proxies the request directly to a Lambda
- AWS & HTTP (non Proxy) integrations use mapping templates.Mapping templates use Velocity Template Language format