How to publish to SNS from Lambda within VPC using VPC Endpoint?


I have set up a VPC with 3 subnets, this to have access to a private RDS instance from my Lambda functions. The RDS <-> Lambda connection works fine, however now I’m not able to publish to SNS.

I found the announcement of VPC Endpoint support for SNS (incl. this blog post and have added a VPC Endpoint Interface with these properties:

All the services are in the eu-west-1 region. I know the code that publish to SNS is correct, as it works when run in a non-VPC environment. The ARN I’m publishing to has remained unchanged: arn:aws:sns:eu-west-1:962446592636:whatever.

I’m aware that a NAT server could be set up to avoid this issue, but I’d prefer to use VPC Endpoints if possible to reduce costs.


It works for me!

I did the following:

  • Created an Amazon SNS topic and subscribed to it
  • Created an AWS Lambda function with no VPC configuration, which sends a message to the SNS topic
  • Tested the Lambda function — message received
  • Created a VPC with a two private subnets
  • Created a Service Endpoint for SNS in the private subnets, with a Security Group allowing All TCP from (for testing purposes)
  • Modified the Lambda function to use the private subnets
  • Tested the Lambda function — message received

So, everything worked fine. I didn’t have to modify any Lambda code.

My Lambda code:

Leave a Reply