Task 3: Edge Lambda pattern with Cognito-protected API Gateway
We will create an Edge Lambda behind API Gateway (protected by the Amplify Authenticator’s Cognito User Pool). That edge Lambda validates input, inspects JWT claims, and invokes your existing “core” Lambda via boto3. This cleanly separates auth and request shaping from your core logic, and it’s reproducible for coursework.
Architecture overview
Edge Lambda: HTTP entrypoint; receives browser request, verifies auth context, validates/normalizes payload, and calls the core Lambda.
Core Lambda: Your existing business logic; no API-facing concerns.
API Gateway HTTP API: Fronts the edge Lambda; uses a Cognito User Pool Authorizer; CORS restricted to your Amplify domains.
Amplify Authenticator: Students sign in; frontend attaches the Cognito ID token in the Authorization header.
Step-by-step setup
1) Create the edge Lambda (Python)
Function: Create a new Lambda (Python 3.12). Name it something like inference-edge.
Env vars:
TARGET_LAMBDA_NAME: Name or ARN of your existing core Lambda.