amazon-web-servicesamazon-vpcipv4

Clarifying auto-assign IP feature


I'm struggling to interpret this AWS feature announcement: AWS supports dynamically removing and adding auto assigned public IPv4 address:

Amazon VPC announces a network interface setting to dynamically remove and add an auto assigned public IPv4 address on EC2 instances. With this capability, customers that no longer require an auto assigned public IPv4 address on their EC2 instance can remove the public IPv4 address, and if needed attach back a new public IPv4 address, by modifying the public IP setting on the network interface. Before today, once a public IPv4 address was auto assigned to EC2 instance it was not possible to remove it. It remained on the network interface for the lifetime of the EC2 instance.

The public IP setting on the network interface makes it easier for customers to be public IPv4 efficient and reduce public IPv4 cost. Customers that no longer need the auto assigned public IPv4 or are migrating to using private IPv4 address for SSH using EC2 instance connect endpoint can simply remove the auto assigned public IPv4 address, instead of recreating their applications on a new EC2 instance with no auto assigned public IPv4 address.

AFAIK, if I launch an instance, and auto-assigned is disabled, my instance will not automatically get a public IP (and vice versa). See this StackOverflow answer on other ways to get an IP address

My questions:

  1. In the above docs announcement, what does "modifying the public IP setting on the network interface" refer to? What is this public IP setting? Is it the auto-assign public IP setting?
  2. If I enable auto-assign IP after my instance has already launched, will it automatically get assigned an IP on the spot? (or do I need to stop/start?)

Solution

  • I presume it would use ModifyNetworkInterfaceAttribute - Amazon Elastic Compute Cloud:

    AssociatePublicIpAddress: Indicates whether to assign a public IPv4 address to a network interface. This option can be enabled for any network interface but will only apply to the primary network interface (eth0).

    In Python, it would use modify_network_interface_attribute - Boto3 documentation:

    response = client.modify_network_interface_attribute(
        ...
        AssociatePublicIpAddress=True|False
    )