Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
How to access the url that invoked my lambda function

I use the serverless framework to deploy my lambda functions. Serverless uses API Gateway to make my endpoints. I know that it's possible to pass the parameters in methods such as GET and use it in lambda by using the event object. The frontend is already deployed and they were using the following URL to call an endpoint:

example.com/api/EG43

`exports.myHandler = async function(event, context) {
        ...

        // somehow access the URL which was used by the frontend 
        // to grab that EG43 and then return the result based on that key.
        // return information to the caller.  
 }

which EG43 is a key that the previous backend was returning the result based on that key. My question is that if it's possible to somehow know what the URL is. the following doc from AWS shows the parameters that can be read by using the handler arguments, but it doesn't have URL.

https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You should be able to access these details two ways:

a. Setup a mapping template, and pass in the details you need as part of the payload. The mapping template is a velocity template with certain variables accessible. See this for details of what you can access.

b. You can setup the lambda in Proxy Integration mode. With this you have access to the raw request. See this for more details.

Here's how you should setup the Lambda in Proxy Integration Mode:

Lambda Proxy Integration Setup

And when the Lambda is setup in Proxy Integration way here's what you get in the event:

{
    "resource": "/abc/version/test",
    "path": "/abc/version/test",
    "httpMethod": "GET",
    "headers": null,
    "queryStringParameters": null,
    "pathParameters": null,
    "stageVariables": null,
    "requestContext": {
        "path": "/abc/version/test",
        "accountId": "1234",
        "resourceId": "resourceId",
        "stage": "Stage",
        "requestId": "AWS Request ID",
        "identity": {
            "cognitoIdentityPoolId": null,
            "cognitoIdentityId": null,
            "apiKey": "API Key",
            "cognitoAuthenticationType": null,
            "userArn": "arn:aws:iam::<acc_Id>:user/yogesh",
            "apiKeyId": "api-key-id",
            "userAgent": "aws-internal/3",
            "accountId": "<AccId>",
            "caller": "<Some caller ID>",
            "sourceIp": "test-invoke-source-ip",
            "accessKey": "<Access Key>",
            "cognitoAuthenticationProvider": null,
            "user": "<Some User Id>"
        },
        "resourcePath": "/abc/version/test",
        "httpMethod": "GET",
        "extendedRequestId": "test-invoke-extendedRequestId",
        "apiId": "API ID, is typically the API GW ID"
    },
    "body": null,
    "isBase64Encoded": false
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!