Lakshya

Networks, Automation, Connectivity & Data Centres · Chapter 8 of 18

Cloud networking, and the bill it generates

VPCs, security groups, endpoints and egress. The concepts are the same as the physical world with different names and a meter running.

6 min read0 diagramsAll 18 chapters

Cloud networking is not a different discipline — it is the same discipline with the cabling replaced by API calls and a bill attached to data movement. Everything from the earlier chapters still applies: subnets are subnets, route tables are route tables, longest prefix match still governs. What is new is that some choices cost money per gigabyte, and those choices are usually made once, early, by someone who did not know.

The building blocks, and their real-world equivalents

Cloud constructPhysical equivalentWhat people get wrong
VPC (Virtual Private Cloud) / VNet (Virtual Network)Your own data centre networkChoosing 10.0.0.0/16 like everyone else, then failing to peer later
SubnetA VLAN with an SVIIn AWS a subnet lives in one AZ — so a subnet is a failure domain, not just an address range
Route tableA router's route tablePublic vs private subnet is defined by whether the route table has an internet gateway. Nothing else
Internet gatewayYour border routerFree. The NAT gateway next to it is not
NAT gatewayAn outbound-only firewallCharged per hour and per GB processed — the most common surprise line on a cloud bill
Security groupA stateful firewall on the instanceStateful — allow inbound and the reply is automatically allowed. Allow-only; you cannot write a deny rule
Network ACLA stateless router ACL on the subnetStateless — you must allow the return traffic explicitly, including ephemeral ports. This is why NACLs break things mysteriously
VPC endpointA private on-ramp to a serviceGateway endpoints (S3, DynamoDB) are free. Interface endpoints cost per hour per AZ plus per GB — but still beat NAT at volume
Transit gatewayA hub routerCharges per attachment per hour and per GB — it is a router with a meter
PrivateLinkA one-way private connection to someone else's serviceGreat security story, and each endpoint has an hourly cost that adds up across a large estate

Security groups versus NACLs — the single most common cloud networking interview question

Security groups are stateful and allow-only. They attach to an instance or ENI. If you allow inbound 443, the response leaves automatically. You cannot express ‘deny’ — absence of an allow is the deny.

NACLs are stateless and support both allow and deny. They attach to a subnet. If you allow inbound 443, you must also allow outbound on ephemeral ports (1024–65535) or the response is dropped. This is why a NACL change frequently breaks something that looks unrelated.

Where each belongs. Use security groups for essentially all normal access control — and reference other security groups rather than IP ranges, so the rule reads ‘the web tier may reach the database tier’ and stays correct as instances change. Use NACLs sparingly, for coarse subnet-level blocks such as denying a known-bad range.

The egress bill, which is a design constraint and not an accounting detail

Data movement pricing is where cloud networking becomes an architecture question. The shape is consistent across providers even though the numbers differ:

  • Inbound from the internet — free, everywhere. This is deliberate.
  • Outbound to the internet — charged per GB, with the first tier being the most expensive and volume discounts arriving only at serious scale.
  • Between availability zones — charged in both directions on AWS. A chatty microservice architecture spread randomly across three AZs can generate a very large bill purely from cross-AZ chatter, and the fix — topology-aware routing that prefers a same-zone endpoint — is usually a configuration change rather than a redesign.
  • Between regions — charged, and more than cross-AZ.
  • Through a NAT gateway — charged per GB on top of whatever the destination charge is. Traffic to S3 through a NAT gateway is paying twice for something a free gateway endpoint would have handled.
  • Leaving the provider entirely — since 2024, all three major providers waive egress fees for customers migrating away, driven by the EU Data Act. This applies to a full exit, not to ordinary traffic, and it is worth knowing precisely because it is often quoted imprecisely.

A worked example, because the arithmetic is the point

A service in ap-south-1 serves 40 TB a month of API responses to the internet, and pulls 15 TB a month from S3 in the same region through a NAT gateway.

LineVolumeApproximate rateMonthly
Internet egress40 TB~$0.109/GB at this tier~$4,460
NAT gateway data processing15 TB$0.045/GB~$690
NAT gateway hours2 AZs × 730 h$0.045/h~$66
S3 → EC2 same region15 TBfree via gateway endpoint$0
Total as built~$5,216
With an S3 gateway endpoint~$4,526 — a $690/month change that takes ten minutes

Rates move and differ by region, so treat these as the shape rather than a quote. The point is the method: identify each leg of data movement, find its rate, multiply, and then ask which legs could be free. Being able to do this arithmetic out loud is unusual among candidates and extremely well received, because it is exactly what the job involves.

Hybrid connectivity: getting your own network in

  • Site-to-site VPN — IPsec over the public internet. Cheap, quick, typically capped around 1.25 Gbps per tunnel, and subject to internet variability. Correct for most companies most of the time.
  • Direct Connect / ExpressRoute / Cloud Interconnect — a dedicated circuit into the provider's network via a colocation facility. You pay a port fee plus reduced egress rates, and you get predictable latency. Worth it above roughly 5–10 TB a month of egress, or when jitter matters — and the break-even calculation is a genuine and impressive thing to be able to sketch.
  • The gotcha — a single dedicated circuit is less reliable than the internet, because the internet reroutes and a cut fibre does not. Two circuits at two locations, or one circuit with VPN backup, is the design that actually improves availability.

Check yourself

Security group or NACL — where does the return traffic problem arise?NACLs. They are stateless, so you must allow ephemeral return ports explicitly. Security groups are stateful and handle it for you.
Your bill has a large NAT gateway line. What do you check first?What is going through it. S3 and DynamoDB should use free gateway endpoints; other AWS services should use interface endpoints; and anything that is bulk traffic to the internet may belong on a different path entirely.
Why is a subnet a failure domain in AWS?A subnet exists in exactly one availability zone. Spreading a service across AZs means spreading it across subnets, and any resource pinned to one subnet is pinned to one AZ.
When does Direct Connect pay for itself?Roughly when monthly egress volume × the per-GB saving exceeds the port and cross-connect fees — commonly in the 5–10 TB/month range — or immediately when you need deterministic latency rather than cheaper bytes.
← Load balancing, proxies and the edgeThe WAN: leased lines, MPLS, SD-WAN and what actually replaced what →