A developer is implementing an AWS Lambda function that retrieves user profile records from a MongoDB database hosted on an Amazon EC2 instance in a private VPC subnet. After processing the records, the Lambda function publishes notifications to an Amazon SNS topic. The Lambda function is configured to access resources inside the same private VPC subnet.
During integration testing, the developer identifies two issues:
1. The Lambda function times out with network errors when attempting to publish messages to the public Amazon SNS endpoint.
2. The function experiences significant latency because it initiates a new database connection for every incoming request.
Which two configuration changes or development practices should the developer implement to resolve these issues? (Select two.)
- Initialize the MongoDB client and connection pool outside of the Lambda handler function.Answer
- Create an interface VPC endpoint for Amazon SNS and associate it with the VPC subnets used by the Lambda function.Answer
- CDeploy the Lambda function in a public subnet and enable public IP assignment in the Lambda configuration.
- DIncrease the Lambda function's execution timeout limit to allow the connection pool to reset after each invocation.
- EUpdate the Lambda function's IAM execution role trust policy to allow the MongoDB EC2 instance's IAM role to assume it.