Search code examples
node.jsamazon-web-servicesaws-lambdaamazon-sqs

Aws SQS Timeout


I have a lambda nodejs which do a SendMessage to a SQS.

But, this command do timeout. There are no error message.

The lambda and sqs are in same VPC and there are endpoint for each.

The policy of the lambda allow it to do SendMessage to the SQS.

The code of lambda work well in an other account. I don't saw any difference between these accounts.

Have you an idea what can cause this timeout ?

I tried to

  • set endpoint
  • call other existing sqs
  • call no existing sqs
  • rebuild sqs, lambda and roles

thanks


Solution

  • Please note that Amazon SQS does not exist "inside" a VPC. It is accessible on the Internet, or via a "VPC Endpoint for SQS" within the VPC.

    If your Lambda function does not need to connect to any other resources inside the VPC, then you should disconnect the Lambda function from the VPC. This will give it automatic access to the Internet and it should be able to call Amazon SQS.

    If your Lambda function does need to connect to other resources inside the VPC (eg an Amazon RDS database), then you will use the VPC Endpoint for SQS to connect to Amazon SQS. The Security Group configuration should be:

    • A security group on the Lambda function (Lambda-SG) that allows All Outbound traffic
    • A security group on the VPC Endpoints (Endpoint-SG) that permits inbound access on port 443 from Lambda-SG (that is, Endpoint-SG should specifically reference Lambda-SG) OR the security group can permit All Inbound access from the VPC's CIDR range or even 0.0.0.0/0.