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.

Papyna
preguntada hace 2 años1477 visualizaciones
3 Respuestas
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
EXPERTO
Uri
respondido hace 2 años
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.

EXPERTO
respondido hace 2 años
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
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas