How to connect to a VPC in a different region

Hi,

I am quiet new to serverless as well AWS lambda. Currently since AWS Lambda is not available in Asia Pacific Mumbai , i am having issues with connecting to VPC hosting my database. I can’t move my database to region where Lambda due to some concerns. I have read the following links:

http://docs.aws.amazon.com/lambda/latest/dg/vpc.html

I tried both updates of using aws cli or changing severless yml file but it displays an error of not able to find the VPC. Any help would be highly appreciated.

Thanks !

Hi,
You could look at cross region peering - https://aws.amazon.com/answers/networking/aws-multiple-region-multi-vpc-connectivity/ and http://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide/Welcome.html

1 Like

Peering is definitely what you need. Just keep in mind that your Lambda functions will need to be VPC-based themselves (and by default, Lambda functions are not VPC-based) in order to leverage the VPC peering (and talk to RDS based in a VPC).

Is there a way to integrate the peering into serverless to any extent or is it a case of doing it manually after deploy, e.g:

  1. configure serverless for VPC
  2. serverless deploy
  3. send peering request from serverless account
  4. accept with other account and do other config

CloudFormation recently added support for VPC Peering connections, which means you can do it in the resources section of your serverless.yml.

It does involve cross-account roles (to accept the peering request in the other account), and there’s a decent walkthrough in the docs.

cheers for the info @rowanu. Turns out I don’t need this approach yet. I was worried that defining VPC details would mean a new VPC is created rather than integrating with my existing VPC but it magically works so I’m all set. It was the fact that you can’t define the ID/name of the VPC that made me think that but obviously that can be looked up from a subnet or security group ID.