Отправка спот-запроса и ожидание его выполнения, похоже, работает.
Далее, как я могу получить идентификатор / объект экземпляра ec2, который создается для проверки, например, IP-адреса и т. Д..?
У меня есть такой код:
def create_spot_instance():
print("Send Spot Request")
ec2_client = boto3.client('ec2')
res = ec2_client.request_spot_instances(
...
)
request_id = res['SpotInstanceRequests'][0]['SpotInstanceRequestId']
print("Wait for request to be fulfilled...")
waiter = ec2_client.get_waiter('spot_instance_request_fulfilled')
waiter.wait(SpotInstanceRequestIds=[request_id])
print("Wait for ec2 instance to boot up...")
# TODO: get instance id the spot instance created
# TODO: wait until spot instance is booted up
# TODO: return object of ec2 instance