Skip to main content

POST /api/domain/update-lambda-edge

Updates the Lambda@Edge function and propagates changes to all CloudFront distributions.

Purpose

This endpoint:
  1. Reads the current lambda_code.js file (with updated bot patterns)
  2. Uploads it to AWS Lambda and publishes a new version
  3. Updates ALL CloudFront distributions to use the new version

Architecture

Use Cases

  • Update bot detection patterns
  • Fix Lambda@Edge bugs
  • Deploy new routing logic
  • Update AI crawler handling

Internal Services

update_lambda_edge

Handles the Lambda update and CloudFront propagation. Location: src/app/apis/domain/update_lambda_edge/handler.py

generate_lambda_code

Generates the Lambda@Edge code with current bot patterns. Location: src/app/apis/domain/update_lambda_edge/generate_lambda_code.py

Lambda@Edge Function

The Lambda@Edge function runs at CloudFront edge locations and:
  • Detects AI bot user agents
  • Routes AI bots to the AI-optimized site
  • Routes regular users to the origin

Propagation Time

CloudFront distribution updates typically take 5-15 minutes to propagate globally.

Response Fields

FieldTypeDescription
statusstring”success” or error
lambda_versionstringNew Lambda version number
distributions_updatedintegerNumber of distributions updated

Code Location

src/app/apis/domain/update_lambda_edge/routes.py