如果已连接,则允许重新关联弹性 IP

Allow Elastic IP to be reassociated if already attached

网络界面有一个有用的选项"Allow Elastic IP to be reassociated if already attached"。如何使用 cloudformation 做到这一点? (或博托)?

无需为 ec2-vpc-only 帐户指定。

[EC2-Classic, VPC in an EC2-VPC-only account] If the Elastic IP address is already associated with a different instance, it is disassociated from that instance and associated with the specified instance. If you associate an Elastic IP address with an instance that has an existing Elastic IP address, the existing address is disassociated from the instance, but remains allocated to your account.

此选项是防止通过控制台意外重新分配 IP 的安全措施。

您使用 AWS::EC2::EIPAssociation 执行此操作。根据文档,如果弹性 IP 地址已经与另一个实例相关联,它将与该实例取消关联并与指定实例相关联。如果您将弹性 IP 地址与具有现有弹性 IP 地址的实例相关联,则现有地址将与该实例解除关联,但仍分配给您的账户。

所以通过CF,重新关联选项是默认的。

有关详细信息,请参阅 AWS::EC2::EIPAssociation