Course contentsShow
← Cloud and Infrastructure
Lesson 490 of 2,9899. Serverless ComputeFree lesson

Function Network Configuration

Connecting functions to VPCs to access private resources while understanding performance implications.

Function Network Configuration

You'll learn how to connect serverless functions to Virtual Private Clouds (VPCs) to access private resources, and why this matters for performance.

Why Functions Need VPC Access

By default, serverless functions run in a platform-managed network with public internet access. This works fine for calling public APIs, but what if your function needs to query a private database or access an internal service that's not exposed to the internet?

VPC connection lets your function communicate with resources inside your private network—like RDS databases in private subnets, internal APIs, or on-premises systems via VPN.

How VPC Configuration Works

Think of VPC-connected functions like employees who can access both the public internet and your company's internal network simultaneously. You configure your function to attach to specific subnets and security groups within your VPC.

When configured:

  • Your function can reach private IP addresses in that VPC
  • Security groups control which resources the function can access
  • The function still maintains internet access (if subnet has NAT gateway)

The Performance Trade-off

Here's the critical part: VPC connections introduce cold start overhead. The platform must create an Elastic Network Interface (ENI) to bridge your function into the VPC. This ENI setup can add several seconds to initial cold starts.

Modern platforms have improved this significantly with shared ENIs across functions, but the latency still exists. If your function doesn't need private resources, avoid VPC configuration to keep cold starts minimal.

Key Takeaway: VPC configuration enables functions to access private resources like databases and internal services, but adds cold start latency—only use it when you truly need private network access.