我需要編寫一個腳本,可以通過其公共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地址? –