AWS - NQE Query to track Public IP usage

  • 31 January 2024
  • 1 reply

AWS - Public IPv4 charge changes


Back on Jul 28, 2023, AWS announced forthcoming changes to their billing for IPv4 public IP usage, which take effect as of Feb 1, 2024. In summary, AWS says, "Effective February 1, 2024, there will be a charge of $0.005 per IP per hour for all public IPv4 addresses, whether attached to a service or not (there is already a charge for public IPv4 addresses you allocate in your account but don’t attach to an EC2 instance).". More information can be viewed here:


Update Apr. 2, 2024: In light of this, Forward Networks can assist with keeping track of your Public IP usage via an improved NQE Query located in “NQE->Library->Forward Library->Cloud->AWS->Public IPv4 Cloud Cost” that will show you what's being used:


* @intent Shows the number and cost of AWS public IPv4 IP addresses

import "L3/IpAddressUtils";

// $0.005 per hour per IP
costPerIpPerDay = 24.0 * 0.005;

isIPv4(subnet) = isPresent(patternMatch(toString(subnet), `{ipv4Subnet}`));

getPublicAllocatedIps(cloudAccount) =
foreach vpc in cloudAccount.vpcs
let publicAllocatedIps = (foreach subnet in vpc.subnets
foreach iface in subnet.ifaces
foreach ip in iface.ipAddresses
where isIPv4(ip) && ip not in privateIpAddressSet
select ip)
let numPublicIps = length(publicAllocatedIps)
select {
regionsOrnetworkBorderGroups: vpc.cloudRegions,

getPublicUnallocatedIps(cloudAccount) =
[{ regionsOrnetworkBorderGroups: (foreach ip in cloudAccount.publicUnallocatedIps select ip.networkBorderGroup),
vpcName: null : String,
vpcId: null : String,
numPublicIps: length(cloudAccount.publicUnallocatedIps)

foreach cloudAccount in network.cloudAccounts
where cloudAccount.cloudType == CloudType.AWS
foreach record in getPublicAllocatedIps(cloudAccount) + getPublicUnallocatedIps(cloudAccount)
let numPublicIps = record.numPublicIps
where numPublicIps > 0
select {
"Cloud Account":,
"Regions or Network Border Groups": record.regionsOrnetworkBorderGroups,
"VPC Name": record.vpcName,
"VPC ID": record.vpcId,
"Count of Public IPs": numPublicIps,
"Daily Cost ($)": float(numPublicIps) * costPerIpPerDay,
"Monthly Cost ($)": float(numPublicIps) * 30.0 * costPerIpPerDay,
"Annual Cost ($)": float(numPublicIps) * 365.0 * costPerIpPerDay


We sincerely hope you will find this useful.

1 reply

Userlevel 2

Great share - thanks @chrisnaish!