serverless-offline icon indicating copy to clipboard operation
serverless-offline copied to clipboard

Support for Lambda Function URLs?

Open bnol opened this issue 2 years ago • 27 comments

Feature Request

Lambda Function URLs have been officially released!

https://aws.amazon.com/blogs/aws/announcing-aws-lambda-function-urls-built-in-https-endpoints-for-single-function-microservices/ https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html

Any plan to support this?

Thanks

bnol avatar Apr 18 '22 11:04 bnol

I'm also waiting for Lambda Function URLs support in serverless-offline. The official Serverless Framework supported as well: https://www.serverless.com/blog/aws-lambda-function-urls-with-serverless-framework

ixartz avatar May 02 '22 16:05 ixartz

I will start taking a look at this from this weekend.

akinboboye avatar May 05 '22 16:05 akinboboye

hi @akinboboye , could you share the progress?

bnol avatar May 20 '22 03:05 bnol

any progress on this? otherwise, would it be worth putting together a PR? looking at the AWS documentation a function URL is invoked with the same request and response objects as api gateway. would it be a matter of reusing some of the existing logic to mock http gateway endpoints?

hilaryosborne avatar Jun 03 '22 04:06 hilaryosborne

I will start taking a look at this from this weekend.

Did you start taking a look @akinboboye ?

abdennour avatar Jun 03 '22 14:06 abdennour

I am also looking for this feature, is there a work around for now? For example having a function that still uses events: - http: just for local/offline usage.

alexcroox avatar Jul 03 '22 21:07 alexcroox

Bumping this, because my team would benefit tremendously from the addition of URL support.

skyler-sidner-improving avatar Jul 20 '22 21:07 skyler-sidner-improving

Would love to have this feature as well. Any updates or workarounds?

EliBates avatar Jul 26 '22 12:07 EliBates

any updates?

asotoglez avatar Sep 20 '22 18:09 asotoglez

My plan is to add support for this in the next coming months - if no one beats me to it.

just skimmed over the docs and it appears that AWS is creating a URL for each function url with any path invoking the function handler. I would imagine that means we would need to create a service with a port for each function url. if someone would define more than 1 function url we would need to assign multiple ports. alternatively, or in addition, we could use one specific port, with the function name defining the path by convention.

functions:
  foo:
    handler: handler.foo
    url: true

  bar:
    handler: handler.bar
    url: true

could create

localhost:3003 localhost:3004

and/or

localhost:3003/foo localhost:3003/bar

dnalborczyk avatar Sep 21 '22 01:09 dnalborczyk

could create

localhost:3003 localhost:3004

and/or

localhost:3003/foo localhost:3003/bar

Or maybe using an option to determine which method the developer wants.

j0k3r avatar Sep 21 '22 07:09 j0k3r

Any updates on this? We are using a bunch of micro-services and the Lambda Function URL, while great as a function has put some hurdles for us developing and testing...

We have moved to use Localstack to be able to run local tests but it's a hassle to develop still... We are now doing kind of an "ugly-fix" for it where we, developing as offline stage add a API GW (Serverless Offline), but in Localstack (local) and the AWS env's we add a Function URL, like:

custom:
  addHttpOffline: # Only used for local testing (offline) as Lambda URL is not (yet) supported by Serverless Offline
    integrationInternal:
      prod: ""
      qa: ""
      test: ""
      local: ""
      offline:
        - httpApi:
            method: '*'
            path: '/integration/internal/{proxy+}'

functions:
  integrationInternal:
    handler: src/integration/handler.internal
    description: Internal integration endpoints.
    url:
      authorizer: aws_iam
    events: ${self:custom.addHttpOffline.integrationInternal.${opt:stage, self:provider.stage}}

This way we can spin up Serverless Offline in development and still have a HTTP endpoint but it doesn't really feel that clean...

QAnders avatar Oct 16 '22 07:10 QAnders

could create

localhost:3003 localhost:3004

and/or

localhost:3003/foo localhost:3003/bar

I'd prefer the second approach and run it on the same port as Serverless Offline. We often have a combination of API GW (external access) and Function URL for internal access and it would be more convenient with one port and an URI prefix for Function URL's, like (where fucould be a editable parmeter):

localhost:3001/  //<-- API GW
localhost:3001/fu/function1/  //<-- Function URL for "function1"
localhost:3001/fu/function2/  //<-- Function URL for "function2"

Sure, it's more to keep track of as a developer, but as Serverless Offline already prints out the URL's at startup I think it would work nicely, and I'd be happy with it! In any case, deployed in AWS you still have to keep track of the individual Function URL's through some variable (e.g. SSM).

QAnders avatar Oct 16 '22 07:10 QAnders

Hi. Any updates on this?

bnol avatar Nov 15 '22 05:11 bnol

Has anyone found a workaround yet? I'm still spawning a server manually locally at the moment but would love to use serverless-offline instead

alexcroox avatar Dec 15 '22 09:12 alexcroox

currently facing the same problems - would be interested in a workaround as well

DavidVaness avatar Jan 11 '23 09:01 DavidVaness

currently facing the same problems - would be interested in a workaround as well

https://github.com/dherault/serverless-offline/issues/1382#issuecomment-1279912772 That's the work-around we are using, locally, running as stage offline we spin up a "Serverless Offline API" to be able to test. You can use the same Authorizer for it and it behaves the same (same event structure)

QAnders avatar Jan 11 '23 10:01 QAnders

okay, this is basically the same as this no?

{
  handler: `${resolvePath(__dirname)}/handler.default`,
   url:true,
  ...(isOffline && { events: [
    {
      http: { path: 'render', method: 'post' },
    },
  ]},
};

DavidVaness avatar Jan 11 '23 10:01 DavidVaness

Hello, any updates in serverless-offilne about official Function URLs support?

vanderAries avatar Mar 20 '23 12:03 vanderAries

AWS has just released Lambda Response Streaming which only works with Lambda Function URLs, so this feature would be very useful!

serg06 avatar Apr 09 '23 20:04 serg06

I have built this plugin as a termporal solution. It works okay for my case. I am running a secondary server that exposes the url functions as HTTP endpoints

MarioSimou avatar Apr 18 '23 21:04 MarioSimou

Hi~ Any updates?

guhyeon avatar Jun 23 '23 09:06 guhyeon

@grakic did you make further progress on supporting Lambda Function URLs?

alexcroox avatar Dec 15 '23 12:12 alexcroox

+1

asychev avatar Jan 18 '24 14:01 asychev

I have built this plugin as a termporal solution. It works okay for my case. I am running a secondary server that exposes the url functions as HTTP endpoints

At this point, I think it is fair to say that the paths of this project and your have diverged. If something as important as this isnt moving ahead, an alternative project is on the way. I'll make some upstream commits your project. Good job. 🙏🙌

mridang avatar Jan 18 '24 14:01 mridang

Are there any plans or ETA?

asychev avatar Mar 15 '24 13:03 asychev

Are there any plans or ETA?

Just use my workaround from above, works flawless

DavidVaness avatar Mar 15 '24 14:03 DavidVaness