Allocate NAT gateway costs
When you associate a Networking Flexible Cost Allocation (FCA) policy with a NAT gateway, the NAT gateway charges are itemized by the resource that generated the usage, at the granularity that you choose in the policy. Without a policy, all of the charges appear as a single charge against the NAT gateway.
The resource type for these policies is natgw. Policies apply to both
zonal and regional NAT gateways.
The following rules apply to NAT gateway policies:
-
You can allocate the
data-transferdimension, thedata-processingdimension, or both. -
The supported reporting granularities are
eni,ec2,subnet,vpc,account, andcidr. -
Allocation applies to traffic that the NAT gateway sends to the internet through an internet gateway, or through a gateway VPC endpoint to Amazon S3 or Amazon DynamoDB. If the NAT gateway instead sends the traffic onward to a virtual private gateway, a transit gateway, another VPC, or a peering connection, that traffic isn't allocated.
-
If other VPCs reach the NAT gateway through a transit gateway for internet access, FCA allocates that traffic and itemizes it by the VPC and account that generated it, even if the policy specifies a more specific granularity such as
subnet,ec2, oreni. This is by design, and keeps resource-level details from being exposed through the transit gateway. -
If the resource that generated the usage for a flow can't be determined, the usage for that flow is billed as usual.
-
FCA meters NAT gateway traffic before a subnet network ACL can reject it. If the NAT gateway's subnet has no network ACL that denies the sender's outbound traffic, your bill is unchanged, because FCA only re-itemizes existing usage. If such a network ACL does deny that traffic, FCA includes the denied traffic in the allocated usage, and the data transfer and data processing charges for the NAT gateway can be higher than they would be without a policy. To avoid this, deny the traffic at its source with a security group rule instead.
Label usage by CIDR range
You can use the cidr granularity to label usage by an IP address range
that you define, instead of by an AWS resource. In
CidrRangeSpecifications, set PrefixesType to one of
the following values, and provide the ranges and labels in
Prefixes.
-
source-prefixes– Label usage by the IP address of the resource that sends traffic through the NAT gateway. -
destination-prefixes– Label usage by the IP address of the traffic's destination.
Prefixes contains from 1 to 100 entries. Each entry has a
CidrRange and a CidrLabel. The following rules apply.
-
A
CidrRangeis a CIDR block, for example10.0.1.0/24. You must specify the network address of the range, with all host bits set to zero. -
A
CidrLabelis 1–64 characters. It must start with a letter or a number, and can contain letters, numbers, hyphens, and underscores. -
If ranges overlap, the usage is labeled with the most specific range that contains the address. For example, if you specify
10.0.0.0/8and10.0.1.0/24, the address10.0.1.5is labeled with the label for10.0.1.0/24. -
If multiple entries specify the same range, the first entry is used.
-
Traffic that doesn't match any range is billed as usual.
Examples
The following examples show common ways to allocate NAT gateway costs.
Example – Label NAT gateway costs by team
In the following example, a NAT gateway in a networking account is shared by two teams. Each team uses its own subnet range. You want the NAT gateway charges attributed to each team.
You create the following policy and associate it with the NAT gateway, using the Amazon VPC console, the AWS CLI, or AWS CloudFormation. The policy allocates both dimensions and labels usage by source range.
After the policy takes effect and you turn on the data in your Cost and Usage Reports, the NAT gateway data processing is itemized by team, as shown in the following table. The first line item is the summary line item for the NAT gateway. Without a policy, your report shows only this line item. The values in the table are examples.
| Shared resource | Allocated to | Owner account | Data processing |
|---|---|---|---|
| arn:aws:ec2:aa-example-1:111111111111:natgateway/nat-0abc | Not applicable | Not applicable | 500 GB |
| arn:aws:ec2:aa-example-1:111111111111:natgateway/nat-0abc | team-a | 111111111111 | 320 GB |
| arn:aws:ec2:aa-example-1:111111111111:natgateway/nat-0abc | team-b | 111111111111 | 180 GB |
Example – Allocate a centralized NAT gateway to spoke VPCs
In the following example, a networking account runs a NAT gateway in a central egress VPC. Spoke VPCs in other accounts send their internet traffic to the egress VPC through a transit gateway. Without a policy, the networking account sees one NAT gateway charge for all of the spoke VPCs. You want the NAT gateway charges attributed to each spoke VPC.
In the networking account, you create the following policy and associate it with the NAT gateway, using the Amazon VPC console, the AWS CLI, or AWS CloudFormation. The policy allocates both dimensions at VPC granularity.
After the policy takes effect, the NAT gateway data processing is itemized by spoke VPC, and each line item also shows the account that owns the VPC, as shown in the following table. The first line item is the summary line item for the NAT gateway. Without a policy, the networking account's report shows only this line item. The values in the table are examples.
| Shared resource | Allocated to | Owner account | Data processing |
|---|---|---|---|
| arn:aws:ec2:aa-example-1:333333333333:natgateway/nat-0abc | Not applicable | Not applicable | 500 GB |
| arn:aws:ec2:aa-example-1:333333333333:natgateway/nat-0abc | vpc-0aaa | 111111111111 | 300 GB |
| arn:aws:ec2:aa-example-1:333333333333:natgateway/nat-0abc | vpc-0bbb | 222222222222 | 200 GB |
The following considerations apply when the NAT gateway is shared through a transit gateway.
-
Usage from spoke VPCs is itemized by VPC and account only. If the policy specifies the
subnet,ec2, orenigranularity, usage from a spoke VPC is itemized by VPC. To itemize by account instead of by VPC, use theaccountgranularity. -
The policy allocates only the NAT gateway charges. Transit gateway charges, such as transit gateway data processing, aren't allocated by this policy.
-
You associate the policy with the NAT gateway in the networking account. You don't associate it with the spoke VPCs or the transit gateway.