1 Answer
- Newest
- Most votes
- Most comments
2
Hello.
If you just want to send messages from Lambda to SNS, there is no need to connect to VPC.
If you have a requirement to connect Lambda to a VPC, please use NAT Gateway or set up a VPC endpoint for SNS.
Even if Lambda is placed in a public subnet, a public IP address is not attached, so a NAT Gateway or VPC endpoint is required to access AWS services.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc-internet.html
https://docs.aws.amazon.com/sns/latest/dg/sns-vpc-tutorial.html
Relevant content
- AWS OFFICIALUpdated 6 months ago

You should attach your function to a private subnet, not a public one. You should also use the SNS VPC Endpoint to access the SNS service.
What seems a bit strange to me is that I tried pushing from Lambda in VPC with same config into SQS and it worked fine so I thought that it should work with SNS. Do SNS and SQS behave differently in this manner?
I can't say for sure without looking at your VPC settings in detail, but I think you have a VPC endpoint configured for SQS. If Lambda is connected to a VPC, outbound communication from Lambda will go through the VPC. Therefore, if there is no NAT Gateway or VPC endpoint in the VPC, you will not be able to access AWS services from Lambda.