Home / AWS

AWSCheat sheetAdvanced

Amazon VPC IPAM cheat sheet: org-wide pools, allocation rules, overlapping CIDRs and IP address history

CLI commands for running Amazon VPC IPAM across an AWS Organization - delegated admin, hierarchical pools, allocation rules, RAM sharing, finding overlapping or non-compliant CIDRs and tracing who used an IP.

Deepak Bhardwaj6 min read

Applies toAmazon VPC IP Address Manager (IPAM) Advanced tier, AWS Organizations, AWS RAM, AWS CLI v2

When you need this

  • A new VPC overlaps with another VPC or an on-premises range, and Transit Gateway or VPN routing breaks.
  • Teams pick CIDRs from a spreadsheet that is out of date.
  • Security asks "who had 10.42.7.19 last Tuesday?"

IPAM gives you one source of truth: pools that hand out CIDRs by rule, monitoring of every VPC in the organization, and IP address history. The commands below assume the Advanced tier. The Free tier covers only part of this, so check the current tier features and pricing before you choose.

Setup

# From the management account: delegate IPAM to the network account
aws ec2 enable-ipam-organization-admin-account --delegated-admin-account-id 111122223333

# From the delegated admin account: create the IPAM with every Region you operate in
aws ec2 create-ipam --description "org ipam" --tier advanced \
  --operating-regions RegionName=eu-west-1 RegionName=eu-central-1 RegionName=us-east-1

aws ec2 describe-ipams \
  --query "Ipams[].{id:IpamId,tier:Tier,private:PrivateDefaultScopeId,public:PublicDefaultScopeId,regions:OperatingRegions[].RegionName}"

Note

IPAM only monitors and allocates in its operating Regions. A VPC in a Region you forgot to add doesn't show up and isn't checked for overlaps. Add Regions with aws ec2 modify-ipam --add-operating-regions RegionName=ap-southeast-2.

Pool hierarchy

A common layout: one top-level pool holding all private space, a pool per Region (pools with a locale), then pools per environment that teams allocate from.

SCOPE=$(aws ec2 describe-ipams --query "Ipams[0].PrivateDefaultScopeId" --output text)

# Top-level pool, no locale
TOP=$(aws ec2 create-ipam-pool --ipam-scope-id $SCOPE --address-family ipv4 \
  --description "corp 10/8" --query "IpamPool.IpamPoolId" --output text)
aws ec2 provision-ipam-pool-cidr --ipam-pool-id $TOP --cidr 10.0.0.0/8

# Regional pool. The locale must match the Region where VPCs will be created
EUW1=$(aws ec2 create-ipam-pool --ipam-scope-id $SCOPE --address-family ipv4 \
  --source-ipam-pool-id $TOP --locale eu-west-1 --description "eu-west-1" \
  --query "IpamPool.IpamPoolId" --output text)
aws ec2 provision-ipam-pool-cidr --ipam-pool-id $EUW1 --cidr 10.16.0.0/12

# Environment pool with allocation rules
PROD=$(aws ec2 create-ipam-pool --ipam-scope-id $SCOPE --address-family ipv4 \
  --source-ipam-pool-id $EUW1 --locale eu-west-1 --description "eu-west-1 prod" \
  --allocation-default-netmask-length 22 \
  --allocation-min-netmask-length 20 \
  --allocation-max-netmask-length 24 \
  --allocation-resource-tags Key=environment,Value=prod \
  --auto-import \
  --query "IpamPool.IpamPoolId" --output text)
aws ec2 provision-ipam-pool-cidr --ipam-pool-id $PROD --cidr 10.16.0.0/14

Provisioning a pool CIDR is asynchronous. Wait for the state to reach provisioned:

aws ec2 get-ipam-pool-cidrs --ipam-pool-id $PROD --query "IpamPoolCidrs[].{cidr:Cidr,state:State,reason:FailureReason}"
Allocation rule Effect
--allocation-default-netmask-length Size used when a VPC asks for a CIDR without a netmask
--allocation-min-netmask-length / --allocation-max-netmask-length Largest and smallest CIDR a VPC may take (a smaller number means a larger block)
--allocation-resource-tags VPCs created from the pool must carry these tags
--auto-import Existing VPCs whose CIDR fits inside the pool are imported as allocations

Share pools with accounts

POOL_ARN=$(aws ec2 describe-ipam-pools --ipam-pool-ids $PROD --query "IpamPools[0].IpamPoolArn" --output text)

aws ram create-resource-share --name ipam-eu-west-1-prod \
  --resource-arns $POOL_ARN \
  --principals arn:aws:organizations::999988887777:ou/o-abc123/ou-prod-xxxxxxxx

Share only the leaf pools that teams should allocate from, not the top-level or regional pools.

Create a VPC from a pool (workload account)

aws ec2 create-vpc --ipv4-ipam-pool-id ipam-pool-0abc123def4567890 --ipv4-netmask-length 22 \
  --tag-specifications 'ResourceType=vpc,Tags=[{Key=environment,Value=prod},{Key=Name,Value=payments}]'

The same parameters work in CloudFormation (Ipv4IpamPoolId, Ipv4NetmaskLength on AWS::EC2::VPC) and in Terraform (ipv4_ipam_pool_id, ipv4_netmask_length on aws_vpc). Use them in your account vending module so nobody types a CIDR by hand.

Reserve ranges that live outside AWS

Block on-premises and partner ranges inside a pool, so IPAM never hands them out:

aws ec2 allocate-ipam-pool-cidr --ipam-pool-id $EUW1 --cidr 10.20.0.0/16 \
  --description "Reserved: Frankfurt DC over Direct Connect"

You can also pass --disallowed-cidrs on a single allocation to skip ranges just for that request.

Inspect allocations

aws ec2 get-ipam-pool-allocations --ipam-pool-id $PROD \
  --query "IpamPoolAllocations[].{cidr:Cidr,type:ResourceType,id:ResourceId,owner:ResourceOwner,desc:Description}" --output table

Release an allocation that is left over from a deleted VPC (IPAM normally does this by itself after the VPC is deleted, with some delay):

aws ec2 release-ipam-pool-allocation --ipam-pool-id $PROD \
  --ipam-pool-allocation-id ipam-pool-alloc-0123456789abcdef0 --cidr 10.17.4.0/22

Find overlapping and non-compliant CIDRs

# Every overlapping resource CIDR in the private scope
aws ec2 get-ipam-resource-cidrs --ipam-scope-id $SCOPE \
  --query "IpamResourceCidrs[?OverlapStatus=='overlapping'].{cidr:ResourceCidr,type:ResourceType,id:ResourceId,vpc:VpcId,owner:ResourceOwnerId,region:ResourceRegion}" \
  --output table

# VPCs not created from a pool, or breaking pool rules
aws ec2 get-ipam-resource-cidrs --ipam-scope-id $SCOPE --resource-type vpc \
  --query "IpamResourceCidrs[?ComplianceStatus!='compliant'].{cidr:ResourceCidr,status:ComplianceStatus,id:ResourceId,owner:ResourceOwnerId}" \
  --output table

# Subnets close to full (IpUsage is a fraction from 0 to 1)
aws ec2 get-ipam-resource-cidrs --ipam-scope-id $SCOPE --resource-type subnet \
  --query "IpamResourceCidrs[?IpUsage > \`0.8\`].{cidr:ResourceCidr,usage:IpUsage,id:ResourceId,vpc:VpcId}" --output table
ComplianceStatus Meaning Action
compliant Allocated from a pool and within its rules None
noncompliant In a pool's range but breaks a rule (size, tags) Fix tags, or accept and document the exception
unmanaged Not allocated from any pool Import it (auto-import or manual allocation) or plan a re-IP
ignored Excluded from monitoring Check that it was excluded on purpose

Warning

OverlapStatus only compares CIDRs that IPAM knows about. On-premises ranges you haven't reserved in a pool, and VPCs in non-operating Regions, are invisible. An empty overlap report is only as good as your pool coverage.

Exclude a resource that should not be monitored (a lab VPC that never connects anywhere):

aws ec2 modify-ipam-resource-cidr --resource-id vpc-0lab000000000000 --resource-cidr 10.99.0.0/16 \
  --resource-region eu-west-1 --current-ipam-scope-id $SCOPE --no-monitored

Who had this IP?

IP address history covers ENIs, instances, VPCs and subnets. It answers incident and audit questions without searching Flow Logs:

aws ec2 get-ipam-address-history --ipam-scope-id $SCOPE --cidr 10.16.7.19/32 \
  --start-time 2026-11-04T00:00:00Z --end-time 2026-11-05T00:00:00Z \
  --query "HistoryRecords[].{type:ResourceType,id:ResourceId,owner:ResourceOwnerId,vpc:VpcId,from:SampledStartTime,to:SampledEndTime}" \
  --output table

History is sampled, not real-time. Use the time windows as approximate and confirm with CloudTrail or Flow Logs when it matters.

Common errors

Error or symptom Cause Fix
create-vpc fails with an allocation error Netmask outside the pool's min/max, or the pool is full Request a size inside the rules, or provision more CIDR to the pool
VPC creation fails on tags Missing required --allocation-resource-tags Tag the VPC at creation with --tag-specifications
Pool not visible in the workload account RAM share not accepted, or shared to the wrong OU Check aws ram get-resource-shares --resource-owner OTHER-ACCOUNTS
Locale error Pool locale doesn't match the VPC's Region Allocate from the pool for that Region
Can't deprovision a pool CIDR Allocations still exist inside it Release or migrate the allocations first

Prevent it next time

  • Make the IPAM pool the only path to a VPC CIDR: account vending and Terraform modules take a pool ID, not a CIDR.
  • Reserve every on-premises, partner and SD-WAN range in the pools on day one.
  • Add new Regions to --operating-regions before the first VPC is created there.
  • Report on unmanaged and overlapping resources weekly and send each one to the owning account.