简体   繁体   中英

Connecting to an ec2 instance in a private subnet using Lambda

My POC project Architecture is:

在此处输入图像描述

It has two ec2 instances:

  1. Private ec2 instance on which I have installed PostgreSQL.
  2. Public NAT ec2 instance via which I ssh into private EC2 instance.

I have configured security ground inbound and outbound rules, which allows login to my NAT ec2 instance, ssh into my private ec2 instance, install postgreSQL and perform CRUD operations.

Now, I want to understand if it's possible to access the postgreSQL data, installed on private ec2 instance via NAT ec2 instance using a Lambda Function.

I am new to AWS Lambda. Any pointers/references will be appreciable.

Thank you!

To do this you will need to add to allow your Lambda to communicate within the VPC.

This will require adding VPC configuration to your Lambda, with it having an ENI added to the subnets you choose.

You will need to allow inbound access on the security group of your EC2 running PostGres to allow access from the Lambda. For this either reference the CIDR range of the subnets or reference the security group attached to your Lambda.

Just to clarify here, a NAT allows only outbound internet connectivity from your EC2 it does not allow direct inbound access to the servers.

There is more information on the Configuring a Lambda function to access resources in a VPC page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM