AWS Lambda using firebase-admin initializeApp timeout

前端 未结 1 907
长发绾君心
长发绾君心 2021-01-24 01:12

I use Lambda to Firebase message. I ref this. But the lambda function still timeout because it cannot connect to google server.

Handler.js

/ [START impor         


        
1条回答
  •  后悔当初
    2021-01-24 01:26

    After a couple hours struggling, I finally find the reason. Because my Lambda using VPC to connect RDS and the network interface of VPC only have private IP.

    AWS document:

    When you add VPC configuration to a Lambda function, it can only access resources in that VPC. If a Lambda function needs to access both VPC resources and the public Internet, the VPC needs to have a Network Address Translation (NAT) instance inside the VPC.

    So I need to create NAT inside the VPC. I follow this Blog and problem solved.

    0 讨论(0)
提交回复
热议问题