> ## Documentation Index
> Fetch the complete documentation index at: https://help.nops.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove Auto-Assigned Public IPv4 From In-Use Instances

> Stop auto-assigning public IPv4 addresses to instances in regions where a NAT gateway already handles outbound traffic.

Every public IPv4 address is billed per hour, including addresses that subnets or launch templates assign to instances automatically at launch. When those instances only need outbound internet access and the VPC already has a NAT gateway, the public addresses are not needed. nOps finds accounts paying for auto-assigned public IPv4 addresses in regions that already run a NAT gateway, and shows the cost of those addresses as the saving.

| | |
| - | - |
| **Cloud** | AWS |
| **Category** | Networking |
| **Service** | Amazon VPC |
| **Action** | Modify |
| **Effort** | Medium |
| **Restart needed** | Yes |
| **Can be rolled back** | Yes |
| **Analysis window** | Last 7 days |
| **Source** | nOps |

## Why it matters

Auto-assign public IP is on by default in default VPCs and in many templates, so fleets of instances, Auto Scaling groups and EKS nodes each pay for an address they do not use.

## How nOps finds it

nOps reads the last 7 complete days of in-use public IPv4 charges for addresses assigned at instance launch, per account. It counts only regions where the same account was billed for a NAT gateway in those 7 days. The saving is the cost of those addresses, scaled to a month, and must be at least \$20 a month. The extra NAT gateway data-processing charge for traffic that moves off the public addresses is not deducted.

## Before you start

A NAT gateway route for the private subnets the instances will use, and permission to modify subnets and launch templates (`ec2:ModifySubnetAttribute`, `ec2:CreateLaunchTemplateVersion`).

## How to implement

1. List the instances with auto-assigned public IPs and confirm none needs direct inbound internet access. Use a load balancer, Session Manager or EC2 Instance Connect Endpoint for access instead.
2. Check that the subnets route outbound traffic through the NAT gateway, or move the instances to private subnets that do.
3. Turn off auto-assign on the subnets: `aws ec2 modify-subnet-attribute --subnet-id ID --no-map-public-ip-on-launch`.
4. Set `AssociatePublicIpAddress` to false in launch templates used by Auto Scaling groups and EKS node groups, then roll the instances.
5. Update Terraform or CloudFormation with the same settings.

## Risks and considerations

* Instances lose any direct inbound access over their public address, and outbound traffic now pays NAT gateway data-processing charges.
* Existing instances keep their address until they are replaced or the address is removed, so the saving arrives as instances are relaunched.
* Idle (unattached) addresses are a separate recommendation.
* To roll back, turn auto-assign back on and relaunch the instances.

## FAQs

> [accordion] Why only regions with a NAT gateway?
>
> Without a NAT gateway, removing the public address would cut the instances off from the internet, and adding one has its own cost.

## Related

* [Release Idle Public IPv4 Address](https://help.nops.io/inform/supported-recommendations/release-idle-public-ipv4-address)
* [Delete Idle NAT Gateway](https://help.nops.io/inform/supported-recommendations/delete-idle-nat-gateway)
* [Supported recommendations](https://help.nops.io/inform/supported-recommendations.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.