问题
I have an AWS lambda function (Django zappa) that is running inside a VPC thus I'm not able to send emails because Lambda isn't connected to the internet, I tried NAT Gatway but with no hope.
- I created a NAT Gatway using one public subnet of the VPC.
- Created another private subnet with a route table that routes 0.0.0.0/0 to the NAT Gateway.
I would appreciate any help.
回答1:
Go to VPC Dashboard and use the Launch VPC Dashboard
Create (Allocate) an elastic IP address and keep it handy. Select the option VPC with Public and Private Subnets
Configure the subnet CIDRs and associate the elastic IP created in the previous step in the form. This will create a NAT Gateway and set it up automatically with correct route tables.
Things to note:
- NAT Gateway should always be in the public subnet.
- Route table of Private Subnet should have a route
0.0.0.0/0
to NAT Gateway - Route table of Public Subnet should have a route
0.0.0.0/0
to Internet Gateway - Lambda function should be configured with the Private Subnet and not the Public Subnet
- Security Group configured in the lambda function should allow outbound to
0.0.0.0/0
(which is there by default, but you should verify)
来源:https://stackoverflow.com/questions/56571314/mailing-isnt-working-in-django-aws-lambda-zappa-behind-a-vpc