ipdetecto.com logo
ipdetecto.com
My IPSpeed
Knowledge Hub
HomeKnowledge HubServerless Computing Ephemeral Ips
© 2026 ipdetecto.com
support@ipdetecto.comAboutContactPrivacyTermsllms.txt
Advanced
5 MIN READ
Apr 13, 2026

Serverless Computing and Ephemeral IPs: The Servers That Don't Exist

Serverless functions like AWS Lambda spin up with a random IP and vanish in milliseconds — learn how ephemeral networking works and what it means for IP whitelisting and security.

Code That Has No Fixed Address

The traditional model of running code on the internet assumed a stable, long-lived server: rent a machine, assign it an IP address, keep it running. Whether that machine was a physical server in a colocation facility or a virtual machine in AWS EC2, it had a consistent identity. You could whitelist its IP, monitor its uptime, and SSH into it when something broke.

Serverless computing discards that model entirely. In platforms like AWS Lambda, Google Cloud Run, Azure Functions, or Cloudflare Workers, your code is packaged as a deployment artifact and stored in the cloud provider's infrastructure. Nothing runs until a request triggers it. When a trigger fires — an HTTP request, a message in a queue, a scheduled timer — the provider allocates a small execution environment, loads your code, runs it, and discards the environment when the function completes or times out. The entire lifecycle can be measured in milliseconds for simple functions.

During that execution window, the function has an IP address. It is an address assigned from the cloud provider's internal pool, allocated at startup, and returned to the pool at shutdown. The same function invoked again one second later may receive a completely different address. These are ephemeral IPs — addresses that exist only as long as the process that holds them.

How Ephemeral IP Assignment Works in AWS Lambda

When a Lambda function is triggered, the AWS control plane selects a worker host from the available fleet and starts a microVM using the Firecracker hypervisor. The microVM receives a private IP address from the VPC network connecting it to the Lambda data plane. This address is internal to AWS's infrastructure — it is not directly reachable from the public internet.

If the Lambda function makes outbound network calls — querying an external API, connecting to a database — those calls are sourced from one of the IP addresses in the NAT gateway or VPC endpoint associated with the Lambda's VPC configuration. Without explicit VPC attachment, Lambda functions run in an AWS-managed VPC and their outbound traffic is NATed through a pool of IP addresses that AWS manages and rotates across all customers using the same regional Lambda environment.

The practical implication: a Lambda function you wrote may exit one of dozens or hundreds of IP addresses on a given day. You cannot tell an external third-party API to whitelist your Lambda function’s egress IP and expect that whitelist to remain valid the next day.

Architecture: Solving the Ephemeral IP Problem

There are three standard architectural patterns for situations where serverless functions need a stable network identity:

Pattern 1: API Gateway as the Public Face

An API Gateway (AWS API Gateway, Kong, Cloudflare) sits in front of all Lambda functions and serves as the public-facing IP identity. External clients talk to the API Gateway's stable domain name or IP address. The Gateway routes requests to whichever Lambda execution environment is currently handling the function. Third parties whitelist the API Gateway's IP, not the Lambda's. This is the standard architecture for public-facing serverless APIs.

Pattern 2: NAT Gateway with Elastic IP

For serverless functions that need to call external APIs that require IP whitelisting, deploy the Lambda in a VPC and route all outbound traffic through a NAT Gateway with an Elastic IP attached. An Elastic IP is a static public IP that AWS assigns to your account and which persists until you release it. All Lambda invocations in that VPC will exit through the same Elastic IP, making whitelisting possible. The trade-off is additional cost (NAT Gateway charges per GB of data processed) and increased cold-start latency from VPC attachment overhead.

Pattern 3: VPC Endpoints for AWS-Internal Services

When Lambda functions only need to communicate with other AWS services (S3, DynamoDB, SQS), VPC endpoints allow traffic to route within the AWS backbone without traversing the public internet at all. No public IP is used or needed, and the traffic never leaves AWS's network infrastructure.

Real-World Use Cases

E-commerce checkout processing: A Lambda function processes payment gateway webhooks. The payment provider requires the webhook consumer to have a whitelisted IP. The team attaches a NAT Gateway with an Elastic IP to the Lambda's VPC. The payment provider whitelists that single Elastic IP. All webhook processing functions share the same outbound address regardless of how many parallel invocations are running.

Rate-limited third-party API calls: A Lambda function fetches data from a weather API that enforces per-IP rate limits. With ephemeral IPs, each cold start may appear to the weather API as a different client, accidentally distributing requests across IPs and complicating rate limit enforcement. Routing through a NAT Gateway with a static IP ensures consistent rate limit tracking.

Log aggregation pipeline: A serverless pipeline processes millions of log events per day using many concurrent Lambda invocations. Because the functions write to DynamoDB via VPC endpoints rather than public internet, no outbound public IP is involved at all. The architecture is simpler and does not require managing static IPs.

Comparison: Serverless vs. Traditional Server IP Behavior

CharacteristicTraditional VM/ServerServerless Function (Default)Serverless + NAT Gateway
IP address stabilityStable (static or DHCP reserved)Ephemeral — changes per invocationStable outbound via Elastic IP
IP whitelisting by third partiesStraightforwardNot feasibleFeasible
Inbound public accessibilityDirect via public IPRequires API GatewayRequires API Gateway
Scaling behaviorManual or auto-scaling with new IPsAutomatic, no IP management neededAutomatic, shared NAT IP
Cold start latencyNone (server always running)Low (no VPC)Higher (VPC attachment overhead)
Cost modelFixed hourly/monthlyPer-invocationPer-invocation + NAT Gateway cost

Security Considerations for Ephemeral Networking

The absence of a persistent IP address is not inherently a security weakness — in many ways, it reduces the attack surface. A server that does not exist for most of the day cannot be port-scanned, probed, or attacked during those hours. There is no persistent process to exploit with a memory corruption vulnerability because the execution environment is freshly allocated for each invocation.

However, ephemeral networking introduces different security considerations:

  • IAM roles replace network-based trust: Because you cannot control which IP a Lambda function will use, access controls for downstream services (databases, S3 buckets, other APIs) must be implemented through identity-based policies (IAM roles in AWS) rather than IP-based network rules. This is generally a more robust model but requires careful role design.
  • Shared network infrastructure risks: Without VPC attachment, Lambda functions share network infrastructure with other AWS customers. This is a multi-tenant environment, and the security model depends entirely on AWS's hypervisor-level isolation.
  • Injection attacks via event data: A Lambda function's primary attack surface is its input data — the event payload. SQL injection, command injection, and path traversal vulnerabilities in function code are the dominant threat, not network-layer attacks.

Common Misconceptions

Misconception 1: 'Serverless functions have no IP address'

Serverless functions absolutely have IP addresses during their execution window. What they lack is a persistent IP address. At the moment a Lambda function runs, it has a network interface with an assigned IP. The confusion arises because developers never need to configure or manage that IP — the platform handles it transparently.

Misconception 2: 'You can never whitelist a serverless function's IP'

You can, but you need to architect for it. By attaching a Lambda function to a VPC and routing outbound traffic through a NAT Gateway with an Elastic IP, the function's external-facing IP becomes stable and whitelistable. This is a standard, well-documented architecture pattern.

Misconception 3: 'Serverless is less secure because you don't control the infrastructure'

The opposite case can be made. The cloud provider manages OS patching, hypervisor security, network isolation, and physical data center security. The developer's security scope is reduced to the function code and its IAM permissions. Smaller scope means fewer places where mistakes can occur, assuming the developer correctly designs IAM policies and validates all input data.

Misconception 4: 'Cold starts are purely a performance problem'

Cold starts also have security relevance. During a cold start, the execution environment is freshly initialized, which means any in-memory state from previous invocations is absent. This is actually a security benefit — secrets or session data cannot accidentally persist between unrelated invocations from different users. But it also means cached security tokens or database connections must be re-established, which developers sometimes handle insecurely by storing credentials in environment variables without proper secrets management.

Pro Tips

  • Use AWS Secrets Manager or Parameter Store rather than Lambda environment variables for credentials. Environment variables are decrypted and visible to anyone with IAM access to the Lambda configuration.
  • Attach an Elastic IP via NAT Gateway only when you genuinely need IP whitelisting. VPC attachment adds cold-start latency (historically 1–3 seconds for ENI attachment, improved with Hyperplane ENIs but still measurable) and costs money for NAT data processing.
  • Use VPC endpoints for all AWS service calls in production workloads. This keeps traffic off the public internet, eliminates the need for outbound internet gateways for AWS service calls, and often reduces latency.
  • Set concurrency limits on Lambda functions that call rate-limited external APIs. Without limits, a traffic spike can spawn hundreds of parallel invocations that all hit the same external API simultaneously, exhausting rate limits and potentially causing errors.
  • Monitor for unexpected IP ranges in outbound connections using VPC Flow Logs. If a Lambda function suddenly starts making connections to unexpected CIDR ranges, that may indicate a server-side request forgery (SSRF) vulnerability being exploited.
  • Test your API Gateway authentication independently of your Lambda function logic. The Gateway's authorization layer is your network-level perimeter — if it can be bypassed to invoke Lambda functions directly, your network security model is incomplete.

Check how your cloud infrastructure's IPs appear to the internet

Frequently Asked Questions

Q.What is an ephemeral IP address in serverless computing?

An ephemeral IP address is a network address that is assigned to a serverless function when it starts executing and released when the function completes. It is not a fixed, persistent address — the same function may receive a different IP on every invocation. The address exists only as long as the execution environment exists, which for many serverless functions is measured in milliseconds to seconds.

Q.How does AWS Lambda handle IP addresses?

By default, Lambda functions run in an AWS-managed network environment. Outbound connections from these functions exit through shared NAT infrastructure with IP addresses managed by AWS. If a Lambda is deployed in a customer-owned VPC, it receives a private IP from the VPC's subnet. Outbound public traffic from VPC-attached Lambdas requires a NAT Gateway. Attaching an Elastic IP to that NAT Gateway gives the function a stable outbound address.

Q.Can I whitelist a serverless function's IP address?

Not directly, because the function's IP changes with each invocation in the default configuration. To achieve a stable IP for whitelisting purposes, deploy the function in a VPC and route outbound traffic through a NAT Gateway with an attached Elastic IP. All invocations of that function in that VPC will then appear to external services as originating from the same Elastic IP address.

Q.What is an API Gateway and why do serverless architectures need one?

An API Gateway is a managed service that accepts inbound HTTP requests at a stable domain name or IP address and routes them to the appropriate backend function or service. Serverless functions lack a persistent public-facing IP, so external clients cannot contact them directly. The API Gateway provides the stable public identity while the underlying functions remain ephemeral. It also handles authentication, rate limiting, request validation, and TLS termination.

Q.Does serverless networking work differently on Google Cloud and Azure?

The core concepts are the same. Google Cloud Run and Cloud Functions use ephemeral IPs by default. Outbound traffic from Cloud Run services can be routed through a Serverless VPC Access connector and a Cloud NAT gateway to achieve a stable external IP. Azure Functions has similar patterns using Virtual Network integration and Azure NAT Gateway. The specific service names differ but the architectural pattern — function in private network, stable outbound IP via NAT — is consistent across providers.

Q.What is a cold start in serverless computing?

A cold start occurs when a serverless platform has no pre-warmed execution environment available for a function and must allocate a new one from scratch. This involves loading the function code, initializing the runtime, and establishing network connections. Cold starts add latency — typically 100ms to several seconds depending on the runtime and VPC configuration. Functions deployed in VPCs experience longer cold starts because network interface attachment takes additional time.

Q.Is serverless computing secure from a network perspective?

From a network perspective, serverless offers a smaller attack surface than long-running servers because there is no persistent process listening on network ports. Functions are invoked through the API Gateway, which controls access. However, serverless introduces different considerations: IAM role misconfiguration, over-permissive policies, and injection vulnerabilities in function code are the primary security risks. Network-layer security is largely handled by the cloud provider.

Q.What is a VPC endpoint and how does it relate to serverless networking?

A VPC endpoint is a privately-routed connection between your VPC and an AWS service (such as S3 or DynamoDB) that does not traverse the public internet. Lambda functions in a VPC can use VPC endpoints to call AWS services without needing a NAT Gateway or internet gateway, keeping all traffic on the AWS internal network. This reduces cost, eliminates public IP exposure for those calls, and often improves throughput.

Q.How do Cloudflare Workers handle IP addresses differently?

Cloudflare Workers run on Cloudflare's global edge network at points of presence distributed worldwide. Each Worker execution runs on whatever edge node handles the incoming request. Outbound requests from Workers exit from Cloudflare's infrastructure IPs, which are published in Cloudflare's IP ranges but are shared across all customers using Workers. Cloudflare does not currently offer a native mechanism to assign a stable, dedicated outbound IP to a specific Worker.

Q.Why can't I just maintain a list of all possible Lambda IP addresses for whitelisting?

AWS publishes its IP ranges in a JSON file at ip-ranges.amazonaws.com, and the Lambda service uses a subset of those ranges for outbound traffic. In theory you could whitelist the entire range. In practice, these ranges are large (covering tens of thousands of addresses), shared with other AWS customers and services, and subject to change when AWS adds capacity. Whitelisting such large ranges defeats the purpose of access control.

Q.What happens to a serverless function's network connection if execution exceeds the timeout?

When a Lambda function reaches its configured timeout, the execution environment is forcibly terminated. Any open network connections — TCP sockets to databases, HTTP connections to external APIs — are abruptly closed. This can leave transactions in an indeterminate state on the remote side. Proper serverless design requires that functions either complete within their timeout or use transactional mechanisms that handle abrupt termination gracefully.

Q.How does serverless computing affect IP-based rate limiting?

Third-party APIs that rate-limit by IP may behave unexpectedly with serverless functions. Without a NAT Gateway, different invocations may exit from different IPs, effectively distributing requests across multiple IP identities and making per-IP rate limits less predictable. With a NAT Gateway providing a single outbound IP, all invocations share one IP identity and one rate limit bucket. For high-volume serverless applications, this centralization must be accounted for in API quota planning.
TOPICS & TAGS
serverlessaws lambdaephemeral ipcloud developmentapi gatewayserverless computing and ephemeral ips guide 2026managing the servers that dont exist in the cloudhow code runs without dedicated stable ip addressesephemeral networking for aws lambda and google cloudscaling websites with temporary on demand serversrouting transient functions through permanent api gatewayswhy whitelisting serverless IPs is impossible for securityembracing fluid on demand networking modelsimpact of serverless on digital identity managementit architecture for modern dynamic cloud developmentborn and deleted in milliseconds networking theorybuilding unshakeable backends without static hardwareephemeral ip lifecycle in high scale web systemssecuring transient microservices from digital threatsfuture of virtualized networking for global appsaws lambda static ip nat gatewayvpc endpoint serverlessgoogle cloud run ephemeralazure functions ip addressescold start networking latency