AWS Amazon API Gateway Summary

What is Amazon API Gateway?

  • Amazon API Gateway is a fully managed service that simplifies creating, publishing, maintaining, monitoring, and securing APIs at any scale.
  • It allows developers to create APIs that act as a “front door” for applications to access data, business logic, or functionality from various backend services.
  • These backend services could include:
    • Workloads running on Amazon EC2
    • Code running on AWS Lambda
    • Web applications
    • Real-time communication applications
  • Developers can create APIs for their own client applications or make them available to third-party developers.

API Gateway Supports:

  • RESTful APIs, which are HTTP-based and use standard methods like GET, POST, PUT, PATCH, and DELETE.
  • WebSocket APIs for real-time, two-way communication between clients and servers.
  • HTTP APIs, offering a simpler way to create APIs for serverless applications and microservices.

Use Cases and Examples

The sources provide an example of building a backend for a mobile application:

  • Use Case: A company develops a mobile app for its e-commerce platform. Users should be able to browse products, place orders, and view order history.
  • Solution:
    • API Gateway exposes a RESTful API for the mobile app to interact with backend services.
    • Different API endpoints are mapped to AWS Lambda functions or Amazon DynamoDB to handle data operations.
    • API Gateway manages authentication to ensure only registered users can access specific functions.

Architecture

  • API Gateway handles tasks like:
    • Traffic management
    • Authorization and access control
    • Monitoring
    • API version management
  • It ensures a consistent developer experience for building AWS serverless applications.

Features

  • Support for stateful (WebSocket) and stateless (HTTP and REST) APIs.
  • Flexible authentication mechanisms, including:
    • AWS IAM policies
    • Lambda authorizer functions
    • Amazon Cognito user pools
  • Canary release deployments for safe rollout of changes.
  • Logging and monitoring:
    • CloudTrail logging for API usage and changes
    • CloudWatch access and execution logging, with the ability to set alarms
  • Custom domain name support.
  • Integration with AWS WAF for protection against web exploits.
  • Integration with AWS X-Ray for performance analysis.
  • Support for AWS CloudFormation templates for API creation.

Basic Parts of API Gateway

  • Request flow: Prepares and validates the HTTP request before it reaches the backend integration.
  • Integration: The backend service that handles the request after authorization and validation. This could be:
    • A Lambda function
    • An HTTP endpoint
    • Another AWS service
  • Response flow: Processes the response from the integration and prepares it for delivery to the client.

Key Takeaways

  • API Gateway simplifies API management and provides a secure and scalable way to expose backend services.
  • It offers various features for authentication, monitoring, traffic management, and integration with other AWS services.
  • Developers can use API Gateway to build serverless applications, integrate with legacy applications, or proxy HTTP requests to other AWS services.