I am trying to publish to SNS from a Lambda in a VPC but my Lambda hangs and eventually times out after a minute or so.
Based on Securing messages published to Amazon SNS with AWS PrivateLink | AWS Security Blog and similar articles I have created a VPC endpoint like so:
Type: AWS::EC2::VPCEndpoint
Properties:
PrivateDnsEnabled: true
SecurityGroupIds:
- security-group-id
ServiceName: com.amazonaws.ap-southeast-2.sns
SubnetIds:
- subnet1-id
- subnet2-id
VpcEndpointType: Interface
VpcId: vpc-blahblah
This still results in my Lambda hanging when publishing to SNS. How to publish to SNS from Lambda within VPC using VPC Endpoint? recommends a AWS::EC2::SecurityGroupIngress which allows all TCP traffic from the VPC's CIDR as well but that doesn't work either.
My Lambda and the VPC endpoint are in the same security group and there are ingress rules to only allow incoming connections from MySQL from some places and all traffic from the VPC as well (as mentioned previously).
What am I missing to make my Lambda be able to publish to an SNS topic?