question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-cloudfront): EdgeFunction NodejsFunction and PythonFunction support

See original GitHub issue

@njlynch 's new EdgeFunction (see https://github.com/aws/aws-cdk/pull/10500) is very handy for when a stack is deployed outside of us-east-1.

As of now, it extends lambda.FunctionProps, which prevents using the convenience lambda operators such as aws-lamdba-nodejs and aws-lambda-python.

It would be great if you could somehow specify that you want to bundle using the convenience operators while still taking advantage of the cross-region behaviors provided by EdgeFunction.

Use Case

I almost always use Typescript alongside aws-lambda-nodejs’s NodejsFunction operator. This provides me type-safety when developing. However, I also want to deploy my main stack in us-west-2, so EdgeFunction is really handy for me.

Proposed Solution

A (potentially naive) solution would be to provide EdgeFunction, EdgeNodejsFunction, EdgePythonFunction, etc.

Another idea would be to somehow specify the type of Lambda you’re using in property, e.g.,

new cloudfront.experimental.EdgeFunction(this, 'EdgeFunction', {
  functionType: cloudfront.experiment.EdgeFunctionType.NODE_JS, // maybe default to regular lamdba.Function here?
  functionProps: { }, // Typescript requires NodejsFunctionProps here
});

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:20
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
njlynchcommented, Feb 9, 2021

Thanks for the feature request.

I agree this would be really useful, and was something discussed in the initial implementation. See also #12498 for a related request. There’s a few options here to proceed, with varying degrees of copy/paste required. 😃. Happy to discuss design options with you, @blimmer (or anyone else who wants to pick this up!).

2reactions
njlynchcommented, Aug 16, 2021

See #15661 for a duplicate issue and good discussion of at least one approach, including this comment ( https://github.com/aws/aws-cdk/issues/15661#issuecomment-884033318 ) which suggests an approach for exposing and extracting the bundling into a re-usable component.

I actually prototyped something along those lines a long time ago, but ran into some slight awkwardness in the API I didn’t love. Curious for the opinions of @eladb , @jogold , and @nija-at about that idea.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class EdgeFunction (construct) · AWS CDK
A Lambda@Edge function added to default behavior of a Distribution // and triggered on every request const myFunc = new cloudfront.experimental.
Read more >
Deploy Lambda@Edge with AWS CDK and TypeScript
Lambda@Edge are Lambdas that are executed in the AWS Cloudfront Locations. ... I took a closer look at NodejsFunction and EdgeFunction and ...
Read more >
@aws-cdk/aws-cloudfront | Yarn - Package Manager
Amazon CloudFront is a web service that speeds up distribution of your static and dynamic web content, such as .html, .css, .js, and...
Read more >
Cloudfront Functions and Lambda@Edge Compared
So, why did AWS release Cloudfront Functions? ... At the moment this is the only supported language in Cloudfront Functions.
Read more >
How do I create a CloudFront distribution without an origin for ...
As AWS support says, CloudFront performs a DNS validity check for the origin domain, but doesn't send requests to the domain (if the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found