Skip to content

Conversation

@abidhasan-aws
Copy link
Contributor

@abidhasan-aws abidhasan-aws commented Nov 13, 2025

work-in-progress

Issue # (if applicable)

Closes #12671

Reason for this change

Users requested a convenient way to deploy TypeScript Lambda@Edge functions without manual bundling. Currently, they must either:

  1. Use EdgeFunction with pre-bundled code
  2. Manually bundle TypeScript with esbuild before deployment
  3. Use NodejsFunction (which doesn't support cross-region deployment for Lambda@Edge)

Description of changes

Adds NodejsEdgeFunction construct that combines:

  • EdgeFunction's cross-region deployment - Automatically deploys Lambda to us-east-1 regardless of stack region
  • NodejsFunction's TypeScript bundling - Uses esbuild to bundle TypeScript code automatically

Key features:

  • Extends EdgeFunction for Lambda@Edge deployment patterns
  • Reuses prepareBundling utility from lambda-nodejs to avoid code duplication
  • Validates runtime is Node.js family only (Lambda@Edge requirement)
  • Supports all NodejsFunction bundling options (minify, sourceMap, external modules, etc.)
  • Placed in experimental namespace consistent with EdgeFunction

Integration test includes:

  • Cross-region deployment test (eu-west-1 → us-east-1)
  • AWS API assertions verifying Lambda exists and CloudFront attachment
  • TypeScript handler to validate bundling works

Description of how you validated changes

  • Added integration test with AWS API assertions
  • Verified TypeScript compilation with getDiagnostics
  • Followed existing EdgeFunction patterns and test structure

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Adds NodejsEdgeFunction construct that combines EdgeFunction's cross-region
deployment capabilities with NodejsFunction's TypeScript bundling via esbuild.

This addresses the feature request in issue #12671 by providing a convenient
way to deploy TypeScript Lambda@Edge functions without manual bundling.

Key features:
- Extends EdgeFunction for automatic us-east-1 deployment
- Reuses NodejsFunction's prepareBundling utility for esbuild integration
- Validates runtime is Node.js family only
- Supports all NodejsFunction bundling options (minify, sourceMap, etc.)
- Includes integration test with AWS API assertions

Closes #12671
@aws-cdk-automation aws-cdk-automation requested a review from a team November 13, 2025 16:06
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 labels Nov 13, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 13, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@abidhasan-aws abidhasan-aws marked this pull request as draft November 14, 2025 15:05
@abidhasan-aws abidhasan-aws force-pushed the add-nodejs-and-python-function-for-edge-lambda branch 2 times, most recently from a1c0bb9 to ba8fc32 Compare November 14, 2025 15:13
Autofix incorrectly removed the helper functions (getRuntime, findLockFile,
findEntry, findDefiningFile) and broke imports. Restored all functions and
fixed import paths.
…ng logic

The prepareBundling function and all helper functions already exist in
aws-lambda-nodejs/lib/bundling-preparation. Use them directly instead
of duplicating the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-cloudfront): EdgeFunction NodejsFunction and PythonFunction support

2 participants