Can't Lambda in VPC access API Gateway?

Asked 2 years ago, Updated 2 years ago, 126 views

I am currently researching API Gateway (websocket) + Lambda + RDS (via RDS Proxy) for my project, and when I set up VPC on Lambda to connect to the database via RDS Proxy, I no longer get messages from Lambda.

Will Lambda in VPC not be able to reply to messages via API Gateway (websocket)?

The message reply from Lambda is as follows:The language is TypeScript

constapiGateway=newApiGatewayManagementApi({
                apiVersion: '2018-11-29',
                endpoint —event.requestContext.domainName+'/'+event.requestContext.stage
            });

            wait apiGateway.postToConnection({
                ConnectionId: event.requestContext.connectionId,
                Data: 'data'
            } as ApiGatewayManagementApi.PostToConnectionRequest).promise();

I was able to return the message above until I set up VPC in Lambda.

When I checked the CloudWatch log, it seems that the processing has not progressed since I called postToConnection, and it has timed out, and the following log is output:

2022-00-00:00:00.280Z 10xx0xx5-9821-4x02-8x05-1x588x7x460x Task timed out after 5.02 seconds

I'm not very familiar with the network, and I'm trying to set the security group inbound and outbound to pass all traffic, or I'm trying to set the subnet with public, but it hasn't changed.

Please let me know if there are any countermeasures.

As for the configuration, the customer wants to develop it with this configuration as much as possible.

aws-lambda websocket vpc

2022-09-30 19:29

1 Answers

The same thing happened.After connecting to the RDS and retrieving the data through lambda in the VPC, I passed the data to lambda that did not set up the VPC and made it run.The lambda is responding by sending out WebSocket.
I would like to know if there is any other good way.


2022-09-30 19:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.