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

API Gateway Lambda integration not fully simulated #780

Closed
dougmoscrop opened this issue Aug 13, 2019 · 8 comments
Closed

API Gateway Lambda integration not fully simulated #780

dougmoscrop opened this issue Aug 13, 2019 · 8 comments

Comments

@dougmoscrop
Copy link

dougmoscrop commented Aug 13, 2019

I've noticed some discrepancy between what an offline event looks like and what a test event in the AWS console looks like using a simple echo function.

Background: I am the author of serverless-http and I have a few open issues with people trying to use Lambda (vs. Lambda-Proxy) integration. These users want to use Connect/Express/Koa/etc. to model their application structure like 'normal', and then just have my library map out the request/response accordingly. I think I can do this, except there's some pieces of information missing.

Here's the actual output (except identity, I redacted that section)

Offline:

{
  "event": {
    "body": {},
    "method": "GET",
    "principalId": "offlineContext_authorizer_principalId",
    "headers": {
    },
    "query": {},
    "path": {
      "any": "testany"
    },
    "identity": {
    },
    "stageVariables": {},
    "isOffline": true
  },
  "context": {
    "awsRequestId": "offline_awsRequestId_cjz9zmrqj000erarehp7v8wfu",
    "clientContext": {},
    "functionName": "serverless-http-test-dev-echo",
    "functionVersion": "offline_functionVersion_for_serverless-http-test-dev-echo",
    "identity": {},
    "invokedFunctionArn": "offline_invokedFunctionArn_for_serverless-http-test-dev-echo",
    "logGroupName": "offline_logGroupName_for_serverless-http-test-dev-echo",
    "logStreamName": "offline_logStreamName_for_serverless-http-test-dev-echo"
  }
}

Actual:

{
  "event": {
    "body": {},
    "method": "GET",
    "principalId": "",
    "stage": "test-invoke-stage",
    "cognitoPoolClaims": {
      "sub": ""
    },
    "enhancedAuthContext": {},
    "headers": {},
    "query": {},
    "path": {
      "any": "testany"
    },
    "identity": {
    },
    "stageVariables": {
    },
    "requestPath": "\/echo\/sync\/{any+}"
  },
  "context": {
    "callbackWaitsForEmptyEventLoop": true,
    "logGroupName": "\/aws\/lambda\/serverless-http-test-dev-echo",
    "logStreamName": "2019\/08\/13\/[$LATEST]975b21fbb56a468ea3cb6948c2cc810a",
    "functionName": "serverless-http-test-dev-echo",
    "memoryLimitInMB": "1024",
    "functionVersion": "$LATEST",
    "invokeid": "1f3389bc-9eda-47b4-ba6a-0da245196f0c",
    "awsRequestId": "1f3389bc-9eda-47b4-ba6a-0da245196f0c",
    "invokedFunctionArn": "arn:aws:lambda:us-east-1:084278336011:function:serverless-http-test-dev-echo"
  }
}

And here's a diff:

Screen Shot 2019-08-13 at 11 39 04 AM

The biggest blocker right now is requestPath. I need this value in order to turn the request object in to an actual URL to dispatch to the web application. The stage missing is probably also worth noting. The other diffs are of no consequence to me but may be of interest to you.

@dnalborczyk
Copy link
Collaborator

hey @dougmoscrop

thank you for filing the issue! I'm pretty sure we can add those missing event props.

@RichiCoder1
Copy link
Contributor

@dnalborczyk @dougmoscrop Looks like the last master supports these event props?

@dnalborczyk
Copy link
Collaborator

@RichiCoder1 I added some of the missing context props (callbackWaitsForEmptyEventLoop, memoryLimitInMB) to master, but invokeid seems to be missing (might be new, not sure).

I didn't add any of the event props [yet].

@RichiCoder1
Copy link
Contributor

It looks like the prop that Doug needed, requestPath, is there? https://github.com/dherault/serverless-offline/blob/master/src/LambdaProxyIntegrationEvent.js#L155

@dougmoscrop
Copy link
Author

I'm not familiar with your code base, but this property is missing for me when not using proxy integration

@RichiCoder1
Copy link
Contributor

Ahh, my bad. Twas me not understanding the route issue

@dnalborczyk
Copy link
Collaborator

some of the props are included in: #776

@dnalborczyk
Copy link
Collaborator

should be fixed with: #776

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

3 participants