Reputation: 559
AWS Lambda MongoDB Atlas Connection Timeout Issue (VPC Peering) I have an AWS Lambda function that connects to a MongoDB Atlas cluster. To enable this connection, I have:
service: Test-api provider: name: aws runtime: nodejs18.x region: ap-south-1 memorySize: 128 timeout: 10 stage: ${opt:stage, 'dev'} environment: MONGO_URI: ${self:custom.mongoUris.${self:provider.stage}} custom: mongoUris: dev: "mongodb+srv://URL" staging: "mongodb+srv://staging-uri" prod: "mongodb+srv://prod-uri" functions: createUserStatus: handler: serverless/functions/userStatus/create.handler vpc: securityGroupIds: - sg-********** subnetIds: - subnet-********** events: - http: path: user-status method: post cors: true plugins: - serverless-offline
Despite these configurations, I am still getting a MongoDB connection timeout error when my Lambda function attempts to connect.
What additional configurations should I check in my AWS VPC setup to ensure connectivity?
Upvotes: 1
Views: 47