Multi-account network architecture: a central network account for the whole bank
Design a bank's AWS network across many accounts: a central network account, shared VPCs with AWS RAM, a shared Transit Gateway, centralised egress, inspection and endpoints, IPAM pools, and guardrails that stop workload accounts building their own way to the internet.
Assumes: .NET 10 LTS (file-based app, no AWS calls) ยท AWS CLI v2 ยท Terraform AWS provider v6 ยท AWS Organizations, AWS RAM, Amazon VPC IPAM ยท Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Explain why banks run networking from a central network account and what stays in workload accounts.
- Share subnets with VPC sharing (AWS RAM) and state exactly what the owner and the participants can and cannot do.
- Combine a shared Transit Gateway, centralised egress, a central inspection VPC and centralised interface endpoints into one design, and know when each is worth it.
- Allocate address space from IPAM pools so overlapping CIDRs become impossible rather than unlikely.
- Write guardrails โ service control policies, VPC Block Public Access, Network Access Analyzer โ so workload accounts cannot create their own internet paths.
- Validate a landing-zone network configuration in C# before anything is deployed.
Prerequisites
- Accounts and AWS Organizations โ OUs, management account, SCPs at a high level.
- VPC peering and Transit Gateway, hybrid connectivity, AWS Network Firewall and private networking patterns.
- Helpful: Boundaries, SCPs, RCPs and resource policies.
- Tools: .NET 10 SDK. No AWS resources are created in this lesson unless you choose the optional exercise.
Why this matters in banking
Banks use many AWS accounts โ one per workload per environment is common โ because an account is the strongest isolation boundary AWS offers: separate IAM, separate quotas, separate billing, separate blast radius. Harbourline has 40 accounts today and expects 150 within three years.
If every account team builds its own network, you get what Harbourline had in its first year: overlapping CIDRs, a dozen NAT gateways each with its own egress policy (or none), peering connections nobody approved, interface endpoints duplicated in every VPC, and no single answer to "what can reach the core banking network?". Security reviews took weeks because each design was different.
The fix is organisational as much as technical: a network team owns a network account (sometimes several: hub, inspection, DNS) and offers connectivity as a product. Workload teams get subnets that are already connected, inspected and logged, and guardrails make it impossible to build around them.
The idea in plain language
Think of the AWS Organization as a city:
- The network account is the city's utility company. It owns the roads (Transit Gateway), the city gates (egress and ingress), the checkpoints (inspection), the telephone exchange (DNS) and the land registry (IPAM).
- Workload accounts are businesses. They rent plots (shared subnets) or build their own buildings connected to the city roads (VPC attachments). They decide what happens inside their buildings (security groups, instances, databases), but they can't build their own road out of the city.
- Guardrails are planning law: no matter what a business wants, it can't build a private road to the motorway (SCP denying internet gateways), and inspectors (Network Access Analyzer) check regularly.
Analogy: Azure folks will recognise this as the Azure Landing Zone "connectivity subscription" with hub-and-spoke or Virtual WAN, plus Azure Policy to stop spokes creating public IPs. The AWS pieces are different products, but the operating model is the same.
What problem the AWS services solve
| Service / feature | Role in the design | Notes and limits |
|---|---|---|
| AWS Organizations + OUs | Account structure; where guardrails attach | SCPs restrict what IAM can do in member accounts; they don't grant anything |
| AWS RAM | Shares subnets, Transit Gateways, Resolver rules, IPAM pools, prefix lists, Network Firewall policies with accounts or OUs | Sharing within the Organization can be enabled without invitations |
| VPC sharing | Several accounts deploy into subnets of one VPC owned by the network account | Same Region; owner manages VPC, subnets, route tables, NACLs, gateways; participants manage their own resources and security groups |
| Transit Gateway (shared) | Connects VPCs from every account and on-premises | Attachments created by workload accounts, accepted and associated by the network account |
| Centralised egress VPC | One set of NAT gateways (and firewall) for the whole Region | Saves NAT cost, centralises egress policy; adds TGW processing cost |
| Inspection VPC | Network Firewall for north-south and east-west traffic | Needs appliance mode on its TGW attachment |
| Centralised interface endpoints | Endpoints in a shared-services VPC used by all spokes | Requires DNS design (private hosted zones associated with spokes) |
| Amazon VPC IPAM | Pools of address space per Region/environment; accounts allocate VPC CIDRs from pools | Advanced Tier billed per active IP; pools shared via RAM |
| SCPs | Deny internet gateways, peering, VPN, public IPs, flow-log deletion outside the network team | Test carefully; SCPs apply to everyone in the account except the management account |
| VPC Block Public Access | Account-level switch that blocks internet ingress/egress through IGWs | Exclusions for approved VPCs/subnets |
| Network Access Analyzer | Proves no unintended paths exist (e.g. IGW โ data tier) | Per-ENI pricing |
| AWS Control Tower / Landing Zone Accelerator | Automate the baseline for new accounts | LZA on AWS has a network configuration file describing all of this โ VERIFY current feature set |
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS equivalent | What's different |
|---|---|---|
| Management groups + subscriptions | Organizations OUs + accounts | AWS accounts are harder isolation boundaries than subscriptions |
| Connectivity subscription (ALZ) | Network account (hub) | Same idea |
| Hub VNet / Virtual WAN hub | Transit Gateway (+ inspection VPC) / Cloud WAN | TGW is a managed router, shared via RAM |
| Spoke VNets peered to hub | Spoke VPCs attached to TGW, or shared subnets in a central VPC | VPC sharing has no direct Azure equivalent: many subscriptions deploying into one VNet's subnets |
| Azure Policy deny public IP / deny route to Internet | SCPs + VPC Block Public Access + declarative policies | SCPs block API calls; BPA blocks traffic |
| Azure Firewall in the hub | Network Firewall in an inspection VPC | Appliance mode on the attachment for symmetry |
| Private DNS zones linked to spokes | Route 53 private hosted zones associated with spoke VPCs (cross-account) + Resolver rules shared via RAM | Cross-account association needs an authorisation step |
| AVNM IPAM / Azure IPAM | Amazon VPC IPAM pools shared with RAM | Allocation rules enforce size and tags |
Architecture
Harbourline's landing zone network
Harbourline uses both connection models on purpose:
- Prod workload accounts own their VPCs (CIDRs allocated from IPAM) and attach them to the shared Transit Gateway. Each prod team controls its own route tables inside its VPC, under guardrails, and gets the strongest isolation.
- Non-prod accounts get subnets shared from network-owned VPCs. Many small dev/test accounts share one dev VPC and one test VPC: fewer TGW attachments, fewer NAT gateways, no IP planning per team.
VPC sharing: who controls what
| Action | Owner (network account) | Participant (workload account) |
|---|---|---|
| Create/modify VPC, subnets, route tables, NACLs, gateways, endpoints | Yes | No |
| Launch resources (EC2, ECS tasks, RDS, Lambda ENIs, ALBs) in shared subnets | Yes | Yes |
| Create security groups in the shared VPC | Yes | Yes (their own) |
| Modify another account's resources or security groups | No | No |
| See other participants' resources | Owner sees ENIs in its subnets; not the resources themselves | No |
| Pays for | VPC-level items such as NAT gateway hours, VPC endpoints, TGW attachment โ VERIFY exact split | Their own resources and their data transfer โ VERIFY |
Constraints worth knowing: sharing works within the same Organization (with sharing enabled in RAM), in the same Region; you cannot share subnets of a default VPC; participants cannot use the owner's default security group โ VERIFY current rules for cross-account security-group referencing in shared VPCs.
Centralised egress and inspection
One firewall policy, one set of NAT gateways (one per AZ), one place for egress logs. Spokes have no internet gateway and no NAT. Details of routing and symmetry are in AWS Network Firewall.
Centralised interface endpoints
Instead of seven endpoints ร three AZs in each of 100 VPCs (2,100 endpoint-AZs, about USD 15,000 a month), put each endpoint once in the shared-services VPC with private DNS disabled, create a Route 53 private hosted zone per service name (for example secretsmanager.us-east-1.amazonaws.com) with an alias to the endpoint, and associate those zones with every spoke VPC. Spokes reach the endpoints over the Transit Gateway. Trade-offs: TGW processing charges on endpoint traffic, and endpoint policies become shared โ use aws:PrincipalOrgID/aws:ResourceOrgID conditions.
Guardrails
Service control policy: no do-it-yourself internet paths
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInternetPathsExceptNetworkTeam",
"Effect": "Deny",
"Action": [
"ec2:CreateInternetGateway",
"ec2:AttachInternetGateway",
"ec2:CreateEgressOnlyInternetGateway",
"ec2:CreateNatGateway",
"ec2:CreateVpcPeeringConnection",
"ec2:AcceptVpcPeeringConnection",
"ec2:CreateVpnGateway",
"ec2:CreateCustomerGateway",
"ec2:CreateVpnConnection",
"ec2:CreateTransitGateway",
"directconnect:*",
"globalaccelerator:Create*"
],
"Resource": "*",
"Condition": {
"ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/hl-network-pipeline" }
}
},
{
"Sid": "DenyTurningOffEvidence",
"Effect": "Deny",
"Action": [
"ec2:DeleteFlowLogs",
"ec2:ModifyVpcBlockPublicAccessOptions",
"ec2:DeleteVpcBlockPublicAccessExclusion",
"ec2:CreateVpcBlockPublicAccessExclusion"
],
"Resource": "*",
"Condition": {
"ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/hl-network-pipeline" }
}
},
{
"Sid": "NoPublicIpOnInstanceLaunch",
"Effect": "Deny",
"Action": "ec2:RunInstances",
"Resource": "arn:aws:ec2:*:*:network-interface/*",
"Condition": { "Bool": { "ec2:AssociatePublicIpAddress": "true" } }
}
]
}Attach it to the Workloads OUs, not to the Infrastructure OU. Notes:
- SCPs restrict every principal in member accounts, including administrators โ but not the management account and not service-linked roles.
- The exception uses a role name pattern; protect that role's trust policy so only the network pipeline can assume it.
- Action names and condition keys should be validated in a sandbox OU first โ VERIFY each action against the Service Authorization Reference before production.
- Pair the SCP with VPC Block Public Access set in each account (or via an Organizations declarative policy โ VERIFY availability), so traffic is blocked even if an IGW somehow exists.
Detective controls
- Network Access Analyzer scope in the security tooling account: "any path from an internet gateway to any ENI in a subnet tagged
Tier=data" โ expected findings: none. - AWS Config rules:
vpc-flow-logs-enabled,restricted-ssh,ec2-instance-no-public-ip,subnet-auto-assign-public-ip-disabledโ VERIFY managed rule names. - CloudTrail alarms on TGW route-table changes, RAM share changes and SCP changes.
Step-by-step implementation
1. Create the Infrastructure OU and network account
Create the network account through your account vending process (Control Tower Account Factory or your own pipeline). Restrict human access; changes flow through the network pipeline role.
2. Enable RAM sharing with the Organization
In the management account: aws ram enable-sharing-with-aws-organization. Shares to OUs then need no invitations.
3. Build IPAM
Delegate IPAM administration to the network account, create a top-level pool 10.16.0.0/12, Regional pool for us-east-1, and environment pools (prod 10.17.0.0/16โ10.18.0.0/16, non-prod 10.19.0.0/16โ10.20.0.0/16) with allocation rules (for example, minimum /20, maximum /16, required tags). Share the pools with the relevant OUs.
4. Build the hub
Transit Gateway with defaults off and auto-accept off, shared with the Workloads OUs; inspection/egress VPC with Network Firewall and NAT; shared-services VPC with interface endpoints and Resolver endpoints; DX gateway and VPN.
5. Offer two connection products
- Shared subnets (non-prod): the network team creates the VPC and shares subnet groups to accounts via RAM.
- Attached VPC (prod): the workload pipeline creates a VPC with a CIDR from IPAM and a TGW attachment; the network pipeline accepts it, associates and propagates per segment.
6. Apply guardrails, then detect
Attach the SCP to Workloads OUs, enable VPC BPA, deploy Config rules, and schedule Network Access Analyzer.
7. Validate configuration as code
Keep the whole network design in a configuration file in Git and validate it in CI (the C# validator below) before any deployment.
AWS Console instructions
- RAM: Console โ Resource Access Manager โ Settings โ Enable sharing with AWS Organizations (management account). Create resource share โ resource type Subnets (or Transit gateways, Resolver rules, IPAM pools) โ principals: OU ARN.
- Shared subnets in a participant account: Console โ VPC โ Subnets shows the shared subnets with the owner's account ID; launch resources normally.
- IPAM: Console โ IPAM โ Create IPAM โ operating Regions โ Pools โ Create pool (top-level, Regional, environment) โ Allocation rule settings.
- SCPs: Console โ AWS Organizations โ Policies โ Service control policies โ Create policy โ attach to OU.
- Network Access Analyzer: Console โ VPC โ Network Access Analyzer โ Create Network Access Scope.
AWS CLI
# Run in the network account unless noted. Read-only commands are safe in any sandbox.
$p = '--profile', 'learn-sandbox', '--region', 'us-east-1'
# (Management account) allow RAM shares within the Organization
aws ram enable-sharing-with-aws-organization --profile management
# Share two subnets with the non-prod OU
aws ram create-resource-share @p --name hl-dev-shared-subnets `
--resource-arns arn:aws:ec2:us-east-1:111122223333:subnet/subnet-0devapp000000000a arn:aws:ec2:us-east-1:111122223333:subnet/subnet-0devapp000000000b `
--principals arn:aws:organizations::999988887777:ou/o-exampleorgid/ou-nonp-11111111 `
--no-allow-external-principals --tags key=Project,value=cea-lab key=Lab,value=m02-l16
# What is shared, and with whom?
aws ram list-resources @p --resource-owner SELF --query "resources[].{Type:type,Arn:arn,Share:resourceShareArn}"
aws ram get-resource-share-associations @p --association-type PRINCIPAL --query "resourceShareAssociations[].{Share:resourceShareName,Principal:associatedEntity,Status:status}"
# IPAM: allocate a /16 for a new prod VPC from the prod pool (the workload pipeline does this)
aws ec2 allocate-ipam-pool-cidr @p --ipam-pool-id ipam-pool-0prod000000000000 --netmask-length 16 --description "hl-cards-prod"
# Or create the VPC directly from the pool - no CIDR typed by a human
aws ec2 create-vpc @p --ipv4-ipam-pool-id ipam-pool-0prod000000000000 --ipv4-netmask-length 16 `
--tag-specifications "ResourceType=vpc,Tags=[{Key=Name,Value=hl-cards-prod},{Key=Project,Value=cea-lab}]"
# (Management account) create and attach the SCP to the Workloads OU
aws organizations create-policy --profile management --type SERVICE_CONTROL_POLICY --name hl-network-guardrails `
--description "No DIY internet paths in workload accounts" --content file://scp-network-guardrails.json
aws organizations attach-policy --profile management --policy-id p-examplepolicy --target-id ou-work-22222222Infrastructure as Code
# Transit Gateway shared with the Workloads OU; attachments must be accepted by the network team.
resource "aws_ram_resource_share" "tgw" {
name = "hl-tgw"
allow_external_principals = false
}
resource "aws_ram_resource_association" "tgw" {
resource_arn = aws_ec2_transit_gateway.hub.arn
resource_share_arn = aws_ram_resource_share.tgw.arn
}
resource "aws_ram_principal_association" "tgw_workloads" {
principal = var.workloads_ou_arn
resource_share_arn = aws_ram_resource_share.tgw.arn
}
# Non-prod shared VPC: subnets shared with the non-prod OU
resource "aws_ram_resource_share" "dev_subnets" {
name = "hl-dev-shared-subnets"
allow_external_principals = false
}
resource "aws_ram_resource_association" "dev_subnets" {
for_each = { for k, s in aws_subnet.dev : k => s if s.tags["Tier"] != "public" }
resource_arn = each.value.arn
resource_share_arn = aws_ram_resource_share.dev_subnets.arn
}
resource "aws_ram_principal_association" "dev_nonprod_ou" {
principal = var.nonprod_ou_arn
resource_share_arn = aws_ram_resource_share.dev_subnets.arn
}
# IPAM with a top-level AWS pool, a Regional pool and a prod pool with allocation rules
resource "aws_vpc_ipam" "main" {
operating_regions {
region_name = "us-east-1"
}
}
resource "aws_vpc_ipam_pool" "aws_top" {
address_family = "ipv4"
ipam_scope_id = aws_vpc_ipam.main.private_default_scope_id
description = "All of Harbourline AWS"
}
resource "aws_vpc_ipam_pool_cidr" "aws_top" {
ipam_pool_id = aws_vpc_ipam_pool.aws_top.id
cidr = "10.16.0.0/12"
}
resource "aws_vpc_ipam_pool" "use1_prod" {
address_family = "ipv4"
ipam_scope_id = aws_vpc_ipam.main.private_default_scope_id
source_ipam_pool_id = aws_vpc_ipam_pool.aws_top.id
locale = "us-east-1"
allocation_min_netmask_length = 16
allocation_max_netmask_length = 20
allocation_resource_tags = { Environment = "prod" }
auto_import = false
description = "us-east-1 prod VPCs"
}
resource "aws_vpc_ipam_pool_cidr" "use1_prod" {
ipam_pool_id = aws_vpc_ipam_pool.use1_prod.id
cidr = "10.17.0.0/16"
}
# Workload side (in the workload account's own stack): VPC CIDR comes from the shared pool
# resource "aws_vpc" "this" {
# ipv4_ipam_pool_id = var.prod_pool_id
# ipv4_netmask_length = 16
# }Complete code
Landing-zone tools describe the network as a configuration file. Harbourline validates that file in CI with a small .NET 10 file-based app before anything is deployed: every VPC CIDR must be inside the AWS supernet and inside its environment's range, no two VPCs may overlap, every prod VPC must attach to the Transit Gateway in a prod segment, no non-prod account may be in a prod segment, and no VPC may declare its own internet gateway unless it is the egress VPC.
{
"awsSupernet": "10.16.0.0/12",
"environments": {
"prod": ["10.17.0.0/16", "10.18.0.0/16"],
"nonprod": ["10.19.0.0/16", "10.20.0.0/16"],
"shared": ["10.16.0.0/16"]
},
"vpcs": [
{ "name": "hub-egress", "account": "network", "env": "shared", "cidr": "10.16.0.0/18", "segment": "shared", "internetGateway": true },
{ "name": "shared-svc", "account": "network", "env": "shared", "cidr": "10.16.64.0/18", "segment": "shared", "internetGateway": false },
{ "name": "payments-prd", "account": "payments-prod", "env": "prod", "cidr": "10.17.0.0/16", "segment": "prod", "internetGateway": false },
{ "name": "accounts-prd", "account": "accounts-prod", "env": "prod", "cidr": "10.18.0.0/16", "segment": "prod", "internetGateway": false },
{ "name": "test-shared", "account": "network", "env": "nonprod", "cidr": "10.19.0.0/16", "segment": "nonprod", "internetGateway": false, "sharedWith": ["ou-nonprod"] },
{ "name": "dev-shared", "account": "network", "env": "nonprod", "cidr": "10.20.0.0/16", "segment": "nonprod", "internetGateway": false, "sharedWith": ["ou-nonprod"] }
]
}using System.Net;
using System.Text.Json;
// Usage: dotnet run lzcheck.cs -- network-config.json
// Exit code 0 = valid, 3 = rule violations, 1 = unreadable input.
if (args.Length != 1 || !File.Exists(args[0]))
{
Console.Error.WriteLine("Usage: dotnet run lzcheck.cs -- <network-config.json>");
return 1;
}
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
var config = JsonSerializer.Deserialize<NetworkConfig>(File.ReadAllText(args[0]), options);
if (config is null)
{
Console.Error.WriteLine("Empty configuration.");
return 1;
}
var errors = new List<string>();
var supernet = Cidr.Parse(config.AwsSupernet);
foreach (var vpc in config.Vpcs)
{
var cidr = Cidr.Parse(vpc.Cidr);
if (!supernet.Contains(cidr))
{
errors.Add($"{vpc.Name}: {vpc.Cidr} is outside the AWS supernet {config.AwsSupernet}");
}
if (!config.Environments.TryGetValue(vpc.Env, out var envRanges))
{
errors.Add($"{vpc.Name}: unknown environment '{vpc.Env}'");
}
else if (!envRanges.Any(r => Cidr.Parse(r).Contains(cidr)))
{
errors.Add($"{vpc.Name}: {vpc.Cidr} is outside the {vpc.Env} ranges {string.Join(", ", envRanges)}");
}
if (vpc.Env == "prod" && vpc.Segment != "prod")
{
errors.Add($"{vpc.Name}: prod VPCs must be in the prod segment (found '{vpc.Segment}')");
}
if (vpc.Env != "prod" && vpc.Segment == "prod")
{
errors.Add($"{vpc.Name}: a {vpc.Env} VPC must never join the prod segment");
}
if (vpc.InternetGateway && vpc.Name != "hub-egress")
{
errors.Add($"{vpc.Name}: only the hub-egress VPC may have an internet gateway");
}
if (vpc.SharedWith is { Count: > 0 } && vpc.Account != "network")
{
errors.Add($"{vpc.Name}: only the network account may share subnets (owner is '{vpc.Account}')");
}
}
// Pairwise overlap check: overlapping VPCs can't be routed through one Transit Gateway.
for (var i = 0; i < config.Vpcs.Count; i++)
{
for (var j = i + 1; j < config.Vpcs.Count; j++)
{
var a = config.Vpcs[i];
var b = config.Vpcs[j];
if (Cidr.Parse(a.Cidr).Overlaps(Cidr.Parse(b.Cidr)))
{
errors.Add($"{a.Name} {a.Cidr} overlaps {b.Name} {b.Cidr}");
}
}
}
foreach (var e in errors)
{
Console.WriteLine("ERROR " + e);
}
Console.WriteLine(errors.Count == 0
? $"OK: {config.Vpcs.Count} VPCs, no overlaps, segments and internet paths follow policy."
: $"{errors.Count} violation(s).");
return errors.Count == 0 ? 0 : 3;
record NetworkConfig(string AwsSupernet, Dictionary<string, List<string>> Environments, List<VpcConfig> Vpcs);
record VpcConfig(string Name, string Account, string Env, string Cidr, string Segment, bool InternetGateway, List<string>? SharedWith);
readonly record struct Cidr(uint Network, int Length)
{
public static Cidr Parse(string text)
{
var parts = text.Split('/');
var bytes = IPAddress.Parse(parts[0]).GetAddressBytes();
var length = int.Parse(parts[1]);
var value = (uint)(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3]);
if ((value & ~Mask(length)) != 0)
{
throw new FormatException($"{text} has host bits set");
}
return new Cidr(value, length);
}
public bool Contains(Cidr other) => other.Length >= Length && (other.Network & Mask(Length)) == Network;
public bool Overlaps(Cidr other) => Contains(other) || other.Contains(this);
private static uint Mask(int length) => length == 0 ? 0u : uint.MaxValue << (32 - length);
}Expected output for the file above:
OK: 6 VPCs, no overlaps, segments and internet paths follow policy.Change dev-shared to "segment": "prod" and "cidr": "10.18.128.0/17" and you get three errors: outside the non-prod range, non-prod in prod segment, and an overlap with accounts-prd.
Code explained line by line
- The JSON file is the network design as data: environments map to address ranges, and each VPC states its owner account, environment, CIDR, Transit Gateway segment, whether it has an internet gateway and whether its subnets are shared.
JsonSerializer.Deserialize<NetworkConfig>with case-insensitive names maps camelCase JSON to C# records.supernet.Contains(cidr)โ every VPC must sit inside10.16.0.0/12, so the data centres can use one summarised route to AWS.- The environment check ties CIDRs to environments (each environment owns a list of aligned /16s from the IP plan), which makes a mis-tagged VPC visible (and lets firewall rules use the environment range).
- The segment rules encode the most important policy in the bank: prod is only in prod, and non-prod never joins prod.
- The internet-gateway rule enforces centralised egress: only
hub-egressmay have an IGW. The SCP enforces the same rule at runtime; the validator catches it at design time. - The sharing rule: only the network account may own shared VPCs.
- The pairwise overlap loop is O(nยฒ), fine for hundreds of VPCs; IPAM prevents overlaps in production, and this catches mistakes in the plan before IPAM is asked.
Cidr.Parserejects host bits (10.20.1.0/16is an error, not silently10.20.0.0/16).- Exit code 3 on violations fails the CI job, so a bad plan never reaches
terraform apply.
Security considerations
โ Learning shortcut โ not for production
This lesson's SCP exempts one role by name pattern across all accounts (arn:aws:iam::*:role/hl-network-pipeline). In production, also restrict who can create a role with that name (otherwise any account admin could create it and bypass the guardrail): deny iam:CreateRole/iam:UpdateAssumeRolePolicy on that role name outside the network account, or use aws:PrincipalAccount to pin the exception to the network account.
- Separation of duties: the network team cannot deploy workloads; workload teams cannot change routing. Both need security-team approval for guardrail changes.
- Blast radius of the hub: the network account is critical infrastructure. Restrict human access (break-glass only), require MFA, enable delete protection on firewalls, and keep routing changes in reviewed pipelines.
- Shared VPC visibility: participants can't see each other's resources, but they share NACLs and route tables owned by the network account. Use security groups for per-team isolation and separate subnets for teams that need it.
- Logging: flow logs from every VPC and TGW, firewall logs and DNS query logs go to the log archive account; SCP denies
ec2:DeleteFlowLogsoutside the network pipeline. - Data residency: sharing and routing are Regional; cross-Region TGW peering should be explicit and reviewed for GDPR / UK GDPR transfer implications by the data-protection officer.
Banking use case
Onboarding a new Cards workload at Harbourline takes one pull request:
- The workload team adds a VPC entry to
network-config.json(env: prod,segment: cde), CI runslzcheck.csand the TGW simulator. - The account vending pipeline creates the account in the Prod/CDE OU, which carries the network guardrail SCP and a stricter CDE SCP.
- The workload pipeline creates the VPC from the prod IPAM pool (no CIDR typed), with flow logs to the log archive and a TGW attachment.
- The network pipeline accepts the attachment, associates it with
rt-cde, propagates it intort-sharedandrt-inspection, and adds the Cards egress allow-list to Network Firewall. - The security tooling account's Network Access Analyzer scope runs and reports no internet paths into the CDE.
Lead time went from three weeks of tickets to under a day, and every step leaves evidence. Whether CDE segmentation satisfies PCI DSS scoping is for the QSA to confirm.
Common mistakes
- Every account builds its own NAT and IGW "just for now". The SCP is easier to apply on day one than on day 300.
- Overlapping CIDRs between accounts because each team picked
10.0.0.0/16. Use IPAM from the start. - Sharing subnets but expecting participants to edit route tables. They can't โ design for that.
- Auto-accept on shared TGW attachments, letting any account join any segment.
- An SCP exception any account can satisfy (see the callout).
- Centralising interface endpoints without DNS planning โ spokes still resolve public IPs.
- Forgetting the management account: SCPs don't apply to it, so don't run workloads there.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Participant can't see shared subnets | RAM sharing with Organizations not enabled, or share targets the wrong OU | Enable sharing in the management account; check principal associations |
Participant gets UnauthorizedOperation on CreateRouteTable | Expected โ owner controls routing | Ask the network team; route tables belong to the owner |
AccessDenied creating a NAT gateway in a workload account | Network guardrail SCP | Use centralised egress, or request a reviewed exception |
| New prod VPC can't reach shared services | TGW attachment pending acceptance or not associated/propagated | Network pipeline accepts and associates; run the TGW simulator |
allocate-ipam-pool-cidr fails | Allocation rules (netmask, tags) not met, or pool exhausted | Check pool rules; request a larger pool |
| Spokes resolve public IPs for centralised endpoints | Private hosted zones not associated with spoke VPCs | Associate the zones (cross-account authorisation) |
| SCP blocks the network pipeline | Exception condition doesn't match the role ARN | Check aws:PrincipalArn pattern; test in a sandbox OU |
Cost and cleanup
This lesson is free: the validator runs locally and nothing is deployed. Indicative costs for the design (us-east-1, checked 2026-11-18 unless marked):
- Transit Gateway: USD 0.05 per attachment-hour + USD 0.02 per GB. 40 VPC attachments โ USD 1,460/month before data.
- Centralised NAT: 3 NAT gateways (one per AZ) โ 3 ร 0.045 ร 730 = USD 98.55/month + USD 0.045/GB โ instead of NAT gateways in each of 40 VPCs (โ USD 3,940/month in hours alone). TGW processing on egress traffic offsets part of the saving.
- Network Firewall (3 AZs): โ USD 865/month + USD 0.065/GB, with NAT hours waived (see AWS Network Firewall).
- Centralised interface endpoints: 7 services ร 3 AZs โ USD 153/month once, instead of per VPC โ VERIFY endpoint rate.
- IPAM Advanced Tier: USD 0.00027 per active IP per hour (from the VPC pricing page) โ 20,000 active IPs โ USD 3,942/month; the free tier covers single-account use.
- VPC sharing and RAM: no charge for sharing itself.
Optional free exercise: if you have two sandbox accounts in an Organization with RAM sharing enabled, share a subnet of a lab VPC from one to the other and launch nothing (sharing costs nothing). Clean up with aws ram delete-resource-share --resource-share-arn โฆ and confirm with aws ram get-resource-shares --resource-owner SELF.
Exercises
- ๐ข Guided: Run
lzcheck.cson the sample file. Then add acards-prdVPC (10.17.128.0/17) and explain the error you get; fix it by choosing a non-overlapping range inside the prod environment. - ๐ก Challenge: Extend
lzcheck.cswith two rules: every VPC must have asegmentthat exists in a newsegmentslist, and no VPC smaller than /20 may be attached to the Transit Gateway (wasteful attachments). Add test cases as extra JSON files. - ๐ด Live problem: A developer in a dev account (participant in the shared dev VPC) complains: "I can't create a NAT gateway, I can't add a route, and my Lambda can't call a partner API on the internet โ your network is broken." Write the response: what's working as designed, what the supported path for partner calls is, and what you'd change (if anything).
Assignment
Produce a one-page network operating model for Harbourline: what the network team offers (products), what workload teams own, the guardrails (SCP excerpt, BPA, detective controls), how onboarding works, and the monthly cost of the hub. Commit network-config.json, lzcheck.cs and the SCP to your portfolio repository.
Solutions
cards-prd at 10.17.128.0/17 overlaps payments-prd (10.17.0.0/16): ERROR payments-prd 10.17.0.0/16 overlaps cards-prd 10.17.128.0/17. The prod environment owns only 10.17.0.0/16 and 10.18.0.0/16, both used โ so there is no free prod space. Fix: allocate a reserved /16 from the IP plan to prod (add 10.21.0.0/16 to environments.prod) and give Cards 10.21.0.0/16. Why it matters: the validator surfaced a capacity problem in the IP plan, not just a typo โ exactly the kind of finding you want before a project starts.
Add "segments": ["prod", "nonprod", "shared", "cde"] to the JSON and to the NetworkConfig record (List<string> Segments). Then:
if (!config.Segments.Contains(vpc.Segment))
{
errors.Add($"{vpc.Name}: unknown segment '{vpc.Segment}'");
}
if (cidr.Length > 20)
{
errors.Add($"{vpc.Name}: {vpc.Cidr} is smaller than /20; use shared subnets instead of a TGW attachment");
}Create bad-segment.json and tiny-vpc.json alongside a valid file, and run all three in CI expecting exit codes 3, 3 and 0. Why: small VPCs each cost a full attachment-hour; shared subnets serve them better.
Working as designed: participants can't create NAT gateways (SCP) or change routes (the network account owns route tables in a shared VPC). That is deliberate: all egress goes through the central inspection VPC with an allow-list.
The supported path: the dev VPC's route tables already send 0.0.0.0/0 to the Transit Gateway โ inspection โ NAT. The Lambda's call fails because the partner's domain is not on the allow-list. Raise a change (owner, ticket, domain) to add it to the dev allow-list; the generator and suricata -T run in CI; the network pipeline deploys it. Also check the Lambda is attached to the shared app subnets (not running outside the VPC) and its security group allows outbound 443.
What might change: if many teams need the same partner, add it to a shared allow-list group; if dev teams need broad internet access for package downloads, offer a separate, logged "dev egress" profile rather than per-account NAT.
Knowledge check
Answer: Only the owner account. Participants launch resources and manage their own security groups.
Answer: Shared subnets are cheaper and simpler for many small accounts (fewer attachments, no IP planning per team). Separate prod VPCs give stronger isolation and team control under guardrails.
Answer: An SCP denying IGW/NAT/peering/VPN creation (prevents the API calls) and VPC Block Public Access (blocks traffic even if a path exists). Detective controls (Network Access Analyzer, Config) confirm.
Answer: Enforcement: VPCs get CIDRs from pools with allocation rules, so overlaps and out-of-plan ranges are prevented rather than detected later; plus Organization-wide monitoring.
Answer: DNS: private DNS off on the central endpoints, private hosted zones for each service name associated with every spoke VPC, plus TGW routing and shared endpoint policies.
Interview questions
- "How would you structure networking for 100 AWS accounts in a bank?" โ Central network account with a shared TGW (defaults off), segments per environment and CDE, centralised egress and inspection, shared-services VPC for endpoints and DNS, IPAM pools, SCP guardrails and BPA, detective checks, and connectivity offered as products through pipelines.
- "VPC sharing or one VPC per account?" โ Sharing for many small or similar workloads (cost, simplicity); separate VPCs where teams need control or strong isolation. Many estates use both.
- "How do you stop someone creating an internet gateway?" โ SCP deny on the relevant
ec2:actions outside the network pipeline role, VPC BPA as a traffic-level backstop, Config/Network Access Analyzer to detect. - "What are the cost trade-offs of centralised egress?" โ Fewer NAT gateways and firewalls, but TGW attachment-hours and per-GB processing on all egress traffic; it usually wins at scale and always wins on governance.
Certification practice
A company wants application teams in separate AWS accounts to deploy workloads into centrally managed subnets, while a network team keeps sole control of route tables, network ACLs and gateways. Which solution meets these requirements?
A. Create a VPC in each account and peer them to a central VPC B. Create the VPC in a network account and share its subnets with the application accounts using AWS Resource Access Manager C. Give the application teams IAM roles in the network account D. Use AWS PrivateLink to expose the subnets
Answer: B. VPC sharing lets participants deploy into shared subnets while the owner controls routing and NACLs. A gives each team its own VPC to manage. C mixes teams into one account. D exposes services, not subnets.
A security team must prevent any IAM principal in workload accounts โ including account administrators โ from creating internet gateways or NAT gateways, while the network team's deployment role in those accounts must still be able to. What should they implement?
A. IAM permission boundaries on all roles in workload accounts
B. An SCP attached to the workload OU that denies the gateway-creation actions unless aws:PrincipalArn matches the network deployment role
C. An AWS Config rule that deletes internet gateways
D. VPC Flow Logs with an alarm on internet traffic
Answer: B. SCPs apply to all principals in member accounts, including administrators, and the condition preserves the network role. A can be removed by administrators. C is detective/reactive. D detects traffic after the fact.
A company keeps finding overlapping VPC CIDRs when connecting new accounts to its transit gateway. The CloudOps team wants new VPCs in any account to receive non-overlapping CIDRs automatically, with size limits. What should they do?
A. Publish the IP plan in a wiki B. Use Amazon VPC IPAM with pools shared to the organization through AWS RAM and allocation rules on netmask length; create VPCs from the pools C. Use AWS Config to detect overlapping CIDRs D. Use a Lambda function to rename VPCs
Answer: B. IPAM pools allocate non-overlapping CIDRs and enforce rules at creation. A and C don't prevent overlaps; D is irrelevant.
Completion checklist
- I can explain the network account's role and what workload accounts own
- I know what VPC sharing participants can and cannot do
- I can draw centralised egress, inspection and endpoints on a shared Transit Gateway
- I can explain the network guardrail SCP and its exception risk
- I ran
lzcheck.csand extended it
Key takeaways
- Networking in a bank is a central product: one network account, shared TGW, central egress, inspection, endpoints and DNS.
- VPC sharing gives participants subnets without routing control; attached VPCs give teams control under guardrails โ use both deliberately.
- IPAM turns "don't overlap" from a hope into a rule.
- Guardrails are layered: SCPs prevent, BPA blocks traffic, Network Access Analyzer and Config detect.
- Keep the network design in Git and validate it before deployment.
Further reading
- Share your VPC with other accounts
- What is IPAM?
- Service control policies
- Block public access to VPCs and subnets
- AWS Transit Gateway pricing
- Amazon VPC pricing (IPAM, NAT gateway)
Next steps: prove isolation end to end in the secure VPC lab, then review the whole module on the module overview.
Independent learning resource โ not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
AWS Network Firewall: centralised inspection and domain-based egress filtering
Understand how AWS Network Firewall inspects traffic, write stateless and Suricata-compatible stateful rules, route traffic through firewall endpoints symmetrically, and choose between distributed and centralised inspection designs.
Lab: prove it's private โ a database the internet cannot reach
Deploy a three-tier VPC with an isolated PostgreSQL database, then prove it is unreachable from the internet with Reachability Analyzer, VPC Flow Logs and a tested C# evidence checker โ and tear it all down within the hour.