Connectin issue from aws lambda (.NET Core)

I am facing the following issue in aws lamda.

{
  "errorType": "TimeoutException",
  "errorMessage": "A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : \"1\", Type : \"Unknown\", State : \"Disconnected\", Servers : [{ ServerId: \"{ ClusterId : 1, EndPoint : \"Unspecified/cluster1.euw4p.mongodb.net:27017\" }\", EndPoint: \"Unspecified/cluster1.euw4p.mongodb.net:27017\", ReasonChanged: \"Heartbeat\", State: \"Disconnected\", ServerVersion: , TopologyVersion: , Type: \"Unknown\", HeartbeatException: \"MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.\n ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known\n   at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch)\n   at System.Net.Dns.GetHostAddresses(String hostNameOrAddress, AddressFamily family)\n   at MongoDB.Driver.Core.Connections.TcpStreamFactory.ResolveEndPoints(EndPoint initial)\n   at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStream(EndPoint endPoint, CancellationToken cancellationToken)\n   at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)\n   --- End of inner exception stack trace ---\n   at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)\n   at MongoDB.Driver.Core.Connections.BinaryConnection.Open(CancellationToken cancellationToken)\n   at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnection(CancellationToken cancellationToken)\n   at MongoDB.Driver.Core.Servers.ServerMonitor.Heartbeat(CancellationToken cancellationToken)\", LastHeartbeatTimestamp: \"2022-12-04T14:06:40.3866692Z\", LastUpdateTimestamp: \"2022-12-04T14:06:40.3866694Z\" }] }.",
  "stackTrace": [
    "at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)",
    "at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)",
    "at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedAsync(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)",
    "at MongoDB.Driver.Core.Clusters.Cluster.SelectServerAsync(IServerSelector selector, CancellationToken cancellationToken)",
    "at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelectionAsync(CancellationToken cancellationToken)",
    "at MongoDB.Driver.MongoClient.AreSessionsSupportedAsync(CancellationToken cancellationToken)",
    "at MongoDB.Driver.MongoClient.StartImplicitSessionAsync(CancellationToken cancellationToken)",
    "at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)",
    "at MongoDB.Driver.IAsyncCursorSourceExtensions.FirstOrDefaultAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)",
    "at Electron.Ingestion.Core.Repository.Mongodb.AbstractRepository.GetSingleAsync[TModel](FilterDefinition`1 filter, String collectionName)",
    "at Electron.Ingestion.Core.Repository.Mongodb.AbstractRepository.Upsert[TModel](TModel model, String collectionName, FilterDefinition`1 filter, UpdateDefinition`1 updateDefinition)",
    "at Electron.Ingestion.Core.Repository.Mongodb.MeterInfoRepository.SaveAsync(Meter model)",
    "at Electron.Ingestion.Service.Handlers.AwsBaseIngestionHandler`2.IngestAsync(TEntity entity, TSyncModel syncModel)",
    "at Electron.Ingestion.Service.Handlers.AwsBaseIngestionHandler`2.Handler(SQSEvent sqsEvent, ILambdaContext context)",
    "at Electron.Ingestion.Service.Functions.MeterInfoFunction.FunctionHandler(SQSEvent sqsEvent, ILambdaContext context)",
    "at lambda_method1(Closure , Stream , ILambdaContext , Stream )",
    "at Amazon.Lambda.RuntimeSupport.Bootstrap.UserCodeLoader.Invoke(Stream lambdaData, ILambdaContext lambdaContext, Stream outStream) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs:line 145",
    "at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass8_0.<GetHandlerWrapper>b__0(InvocationRequest invocation) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/HandlerWrapper.cs:line 56",
    "at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs:line 176"
  ]
}