AWS Lambda: Unable to access SQS Queue from a Lambda function with VPC access

后端 未结 5 2067
独厮守ぢ
独厮守ぢ 2021-02-07 07:25

I have a Lambda function that needs to read messages from an SQS queue using it\'s URL. Then it needs to insert that data to Cassandra running on a server inside a VPC.

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-07 07:49

    I was unable to get either of the other two answers to this question to work. Perhaps this is due to one or more mistakes on my part. Regardless, I did find a workaround that I wanted to share, in case I'm not alone with this problem.

    Solution: I created two Lambda functions. The first Lambda function runs inside my VPC and performs the desired work (in mandeep_m91's case, that's a data insertion to Cassandra; in my case is was accessing an RDS instance). The second Lambda function lives outside the VPC, so I could hook it up to the SQS queue. I then had the second Lambda function call the first, using the information found this this StackOverflow Q&A answer. Note, the linked question has both node.js and Python examples in the answers.

    This will effectively double the cost of making a function call, since each call results in two function executions. However, for my situation, the volume is so low it won't make a real difference.

提交回复
热议问题