[英]Python boto - How can I get allocation id of elastic ip
当我使用boto(用于aws的python sdk)将弹性ip分配给我在vpc中的实例时,它报告了以下错误:
<Response>
<Errors>
<Error>
<Code>InvalidParameterCombination</Code>
<Message>You must specify an allocation id when mapping an address to a network interface</Message>
</Error>
</Errors>
<RequestID>d0f95756-c36f-417a-9fa9-1158c4aa19e9</RequestID>
</Response>
但我在ec2-medata中找不到分配ID。
有人知道如何从API获取分配ID?
我已经在控制台中看到了它:
try: conn = boto.ec2.connect_to_region(zone, aws_access_key_id='a-id', aws_secret_access_key='s-id',debug=2) conn.associate_address(allow_reassociation=True, public_ip=kw['ip'], network_interface_id=nid, dry_run=True)
如果使用get_all_addresses
它应该返回一个Address
对象列表,这些对象具有与之关联的allocation_id
属性。 对于与VPC关联的任何地址, allocation_id
将为非None。
import boto.ec2
c = boto.ec2.connect_to_region('us-east-1')
addresses = c.get_all_addresses()
for addr in addresses:
print('%s - %s' % (addr.public_ip, addr.allocation_id)
这有帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.