In order to allow queries in AWS Athena to a RDS PostgreSQL DB in the same AWS account, I have followed this guide to set up Athena Federated Query with a Lambda Connector.
The connector works just fine. Now, there is a security group which the newly created lambda function and the target RDS DB are both associated with. The inbound rules of this security group allow any source to send requests to port 5432 (default Postgres port):
If I drop these rules, Athena queries for this data source fail (Failed to invoke lambda function due to com.amazonaws.services.lambda.invoke.LambdaFunctionException: 0: org.postgresql.util.PSQLException: The connection attempt failed.
). Is there a way to make these inbound rules less permissive while keeping the Lambda connector intact?