By using AWS re:Post, you agree to the AWS re:Post Terms of Use

POST Request Made from Within Lambda Only Receiving a Not Found Response

1

We have an API Gateway that uses a lambda integration (the lambda is IN our VPC), our internal system POSTs to the api gateway and then our lambda triggers, within this lambda we POST out to a 3rd party service, this POST works successfuly and we create a resource on the 3rd party services portal, however the request comes back to us with a Not Found response and this breaks our flow.

When calling the 3rd party service from my local postman I get back a proper 201. We have checked our security groups, our NAT Gateway, all WAFs and everything seems to allow the traffic into our VPC and should allow a proper response to the lamba initiated POST request. I figured if any security settings were blocking the response from the 3rd party we would see a timeout on the response but we don't. Is there anything in AWS that could possibly be sending a Not Found response instead?

I should also note that we added an api call to another public api (dictionary api) just for testing in the same lambda and that call works perfectly fine and we get a full proper response back.

3 Answers
0

Based on the information provided, it seems that the issue is not likely related to AWS infrastructure or networking configuration, but rather to how the Lambda function is handling the response from the third-party service. Here are a few points to consider:

  1. The fact that you're receiving a "Not Found" response instead of a timeout suggests that the request is reaching the third-party service and a response is being returned. This indicates that your network configuration (VPC, NAT Gateway, security groups) is likely correct.

  2. The successful call to the dictionary API further supports that your Lambda function has proper internet access and can make outbound requests.

  3. The discrepancy between the Postman response (201 Created) and the Lambda response (Not Found) suggests that the issue might be in how the Lambda function is processing or interpreting the response from the third-party service.

Here are some steps you can take to troubleshoot:

  1. Log the entire response object (status code, headers, and body) from the third-party service within your Lambda function. This will help you understand exactly what response the Lambda is receiving.

  2. Check if the third-party service is returning different responses based on the request origin. Some services might behave differently when called from AWS IP ranges compared to your local machine.

  3. Verify that your Lambda function is correctly parsing and handling the response from the third-party service. There might be an issue in the code that's misinterpreting a successful response as "Not Found".

  4. Ensure that your Lambda function has the latest SDK or library for interacting with the third-party service, as there could be compatibility issues.

  5. Check if the third-party service requires any specific headers or authentication that might be missing in the Lambda request but present in your Postman request.

  6. If possible, try to replicate the exact request your Lambda is making using Postman, including all headers and body content, to see if you can reproduce the issue.

  7. Consider using AWS X-Ray to trace the request and get more detailed information about the interaction between your Lambda and the third-party service.

If after these steps you're still encountering issues, you may need to reach out to the third-party service provider to see if they can offer any insights into why the responses might differ between your local environment and AWS Lambda.
Sources
Troubleshoot networking issues in Lambda - AWS Lambda
Troubleshoot ETIMEDOUT error in my Lambda function | AWS re:Post

profile picture
answered 10 days ago
profile picture
EXPERT
reviewed 10 days ago
0

Hi,

As you're receiving a "Not Found" response instead of a timeout, the request is reaching the third-party service and a response is being returned. So, your network config is probably correct.

What I'd rather check are the credentials that you use for the remote service: they are probably different between your laptop and the Lambda.

Some applications - to maximize security - don't say 403 (Auth issue) but 404 when you try a REST action on an object that you're not allowed to. This way they don't disclose to the unauthorized object exist.

So, check the credentials of your Lambda toward the remote service. The issue is probably there!

Didier

profile pictureAWS
EXPERT
answered 10 days ago
profile picture
EXPERT
reviewed 10 days ago
0

Hello,

I understand that when your Lambda is returning NOT FOUND error from the third-party service. :

The "Not Found" response, rather than a timeout, indicates that the request is reaching the third-party service. This, along with successful calls to other APIs, suggests proper network configuration and internet access. The discrepancy between Postman and Lambda responses points to a potential issue in how the Lambda function processes the third-party service's response, rather than a general networking problem.

I also found a few third party articles who faced the similar issue which might help[+]

[+] https://stackoverflow.com/questions/62699781/receiving-a-404-error-on-aws-lambda-post-request

In case you have additional queries or follow-up queries or if the problem still persists regarding AWS API Gateway or Lambda, we may require details that are non-public information to assist you better. Please open a support case with AWS using the following link.

AWS
answered 10 days ago
profile picture
EXPERT
reviewed 10 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions