Allow Lambda to Access AWS Services+VPC+Internet

0

Hi,

Is that possible to allow a Lambda to access 3 things (nearly the everything of AWS) ?

  1. AWS services, such as S3, DynamoDB
  2. VPC, to mount EFS
  3. Internet

I know that Lambda could access 1+3 as default but no 2, but I'm not sure if Lambda could access 3 things together, tried to allow Lambda access 3 from VPC but failed, and my EFS was created with existed subnet and it's being used by EC2 instances.

Thanks a lot.

3 Risposte
3

By default Lambda functions has access to the internet, including AWS services, but not to private resources in a VPC. You can attach a Lambda to a private subnet in a VPC and then it will have access to private resources in the VPC, but not to the internet or AWS services. If you want all, you need to attach the function to a private subnet in a VPC, create a NAT Gateway in a public subnet and route the traffic to the GW. This will give you access to both the VPC and the internet, including AWS services. For some services (e.g., DynamoDB, S3, etc.) you can also create VPC endpoints. This will reduce the cost of the traffic to those services, but it also adds cost for the endpoints themselves, so you will need to check which options is best for you.

profile pictureAWS
ESPERTO
Uri
con risposta 2 anni fa
0

A VPC Lambda will be able to access the Internet if it's in a subnet with at least outbound internet access, i.e. with routing to a NAT gateway/instance or Internet Gateway. See https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/ for example.

ESPERTO
con risposta 2 anni fa
0

Thanks for all !

It worked after attaching VPCE to the private route table, then the Lambda could access services plus Internet access plus VPC resource.

Papyna
con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande