How to setup Lambda Function URLs with Server-Sent Events (SSE) Streaming

Last updated: May 23, 2025

Setup Lambda Function URL

  1. Create a new Lambda function in your AWS infrastructure using Terraform with the following configurations:

    • Enable Function URL with Authentication set to NONE

    • Set invoke mode to RESPONSE_STREAM for SSE support

  2. Configure Content Security Policy (CSP) in your infrastructure to allow the Lambda Function URL:

    • Add the Lambda Function URL to the connect-src directive in your CSP configuration

    • Update CSP settings dynamically through Terraform for each environment

  3. Set up CI/CD pipeline using GitHub Actions:

    • Create deployment workflows for the Lambda function

    • Configure environment-specific variables and settings

  4. Configure additional security measures:

    • Implement AWS WAF for enhanced security

    • Set up appropriate concurrency limits for the Lambda function

Usage

After setup, the Lambda Function URL can be used to establish SSE streaming connections. Ensure that:

  • Your application's CSP is properly configured to allow connections to the Lambda Function URL

  • The health endpoint returns a 200 status code when tested

  • Web adapter initialization is properly configured with required environment variables