我需要编写一个脚本,可以通过其公共dns启动aws实例, 我可以使用具有实例名称的过滤器启动实例,但如果我尝试使用{tag:'Public DNS':my_publicdns}进行过滤,则会出现错误。公共DNS能够过滤吗?用于连接到亚马逊ec2实例公共dns的脚本
my_publicdns = 'ec2-1-2-3-4.eu-west-1.compute.amazonaws.com'
myinstance = 'GA_brian_burroughs'
def start_instance():
try:
inst = conn.get_all_instances(filters={'tag:Name': myinstance})[0].instances[0]
except Exception:
print('Error:', myinstance, 'not found!')
if not inst.state == 'running':
print('Starting', myinstance)
inst.start()
else:
print(myinstance, 'already running or starting up!')
它是否具有弹性IP地址,或只是启动实例时分配的IP地址? –