在 AWS 中,如何使用 boto3 创建弹性 ip?或者更一般地使用 python?

In AWS, how to create elastic ip with boto3 ? or more generaly with python?

我想用 python 脚本创建一个弹性 ip。它没有在文档中找到方法。

使用Allocate Address

Acquires an Elastic IP address.

An Elastic IP address is for use either in the EC2-Classic platform or in a VPC. For more information, see Elastic IP Addresses in the Amazon Elastic Compute Cloud User Guide

    import boto3

    client = boto3.client('ec2')
    addr = client.allocate_address(Domain='vpc')
    print addr['PublicIp']