Skip to content

Conversation

@abidhasan-aws
Copy link
Contributor

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

Issue # (if applicable)

Closes #12671

Reason for this change

Currently, there is no construct that automatically bundles TypeScript code for Lambda@Edge functions. EdgeFunction handles cross-region deployment but requires pre-bundled JavaScript.

This forces users manually bundle core before using EdgeFunction.

Description of changes

Introduces NodejsEdgeFunction construct that bundles TypeScript code for EdgeFunction, enabling automatic TypeScript compilation for Lambda@Edge deployments.

Extracted bundling utility functions from NodejsFunction into a shared module (function-helpers.ts) that both NodejsFunction and NodejsEdgeFunction use, eliminating code duplication while maintaining consistent bundling behavior.

Before

image

After

image

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