2.1.2.1. API Gateway Endpoints & Integrations
First Principle: API Gateway endpoints provide public or private access to your APIs, while backend integrations connect them to your application's logic, creating a seamless and secure API surface.
Amazon API Gateway serves as the entry point for your API traffic. Understanding how to configure its endpoints and integrate them with your backend services is fundamental for building functioning APIs.
Key API Gateway Endpoints:
- Edge-optimized endpoint: (Default) API requests are routed through an Amazon CloudFront network to the nearest API Gateway region. Best for global clients.
- Regional endpoint: The API is hosted in a specific AWS Region. Best for clients in the same Region or when using a separate CloudFront distribution.
- Private endpoint: Accessible only from within your Amazon VPC via an interface VPC endpoint. Best for internal APIs.
Key API Gateway Integrations:
- Lambda integration: Invokes an AWS Lambda function directly. The most common integration for serverless APIs.
- HTTP integration: Forwards requests to any publicly accessible HTTP endpoint (e.g., an EC2 instance or on-premises server).
- AWS service integration: Directly invokes other AWS services like DynamoDB or SQS.
Scenario: You are developing a public-facing REST API for a mobile application that needs to serve users globally with low latency. The API's logic is implemented using AWS Lambda functions.
Reflection Question: How would you configure API Gateway endpoints (e.g., Edge-optimized) and integrate them with AWS Lambda functions to create a scalable and efficient API surface for your global mobile application?