Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serverless Integration Option Support #23

Closed
ricxsar opened this issue Jun 14, 2017 · 2 comments
Closed

Serverless Integration Option Support #23

ricxsar opened this issue Jun 14, 2017 · 2 comments

Comments

@ricxsar
Copy link

ricxsar commented Jun 14, 2017

Hi. Do you have any plans on supporting lambda integration? I would like to use the User Pool as my authentication of the API and I need to specify the integration type as lambda to use the User Pool claims.

Here is my partial serverless.yml definition.

functions:

  # Test API
  test:
    handler: handler.main
    events:
      - http:
          path: / # this matches the base path
          method: ANY
          integration: lambda
          authorizer:
            arn: ${self:custom.userPoolARN}
            claims:
              - custom:organization
              - cognito:groups
      - http:
          path: /{any+} # this matches any path, the token 'any' doesn't mean anything special
          method: ANY
          integration: lambda
          authorizer:
            arn: ${self:custom.userPoolARN}
            claims:
              - custom:organization
              - cognito:groups

Here is my handler file.

'use strict';

import serverless from 'serverless-http';
import express from 'express';

const app = express()

app.get('/', function (req, res) {
  res.send('Hello World!')
})

module.exports.main = serverless(app);

When I try to deploy it using the above configuration, the following output is return on the API Gateway.

{"statusCode":404,"headers":{"x-powered-by":"Express","content-security-policy":"default-src 'self'","x-content-type-options":"nosniff","content-type":"text/html; charset=utf-8","content-length":155},"body":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET [object%20Object]</pre>\n</body>\n</html>\n"}
@dougmoscrop
Copy link
Owner

I would be open to PRs that help support this (provided they don't create a lot of complexity/maintainability issues), but I can't see myself having time to work on it, sorry!

@dougmoscrop
Copy link
Owner

Just FYI I've been poking around and the Lambda integration style is substantially different from Lambda-Proxy. To be honest, I'm not even sure what you would expect/want the behaviour to be.

To anyone interested in working on this, I think you'd need to take the path argument (which is an object rather than a string when using Lambda integration) and then back-fill in the values in to the requestPath.

Note for offline users, this would fail, unless this is fixed: dherault/serverless-offline#780

Just to be clear: I don't intend to work on this, since I have no use case for non-proxy itegrations, but if someone does come to use it, I hope this information saves you some time.

@dougmoscrop dougmoscrop closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants