我目前正在执行此操作,以便通过lambda函数启动EC2按需实例:
ec2 = boto3.resource('ec2', region_name='us-east-2')
instances = ec2.create_instances(
ImageId='ami-0c709cc4edbf9a8c0',
MinCount=1,
MaxCount=1,
KeyName="mykey",
InstanceType="m4.large",
IamInstanceProfile={'Arn': 'arn:aws:iam::231412431243:instance-profile/myimage'},
UserData=user_data_script
是否可以在此处添加一个属性,该属性可以作为竞价型实例运行?
答案 0 :(得分:3)
create_instances()
命令中有一个用于竞价型实例的参数:
InstanceMarketOptions={
'MarketType': 'spot',
'SpotOptions': {
'MaxPrice': 'string',
'SpotInstanceType': 'one-time'|'persistent',
'BlockDurationMinutes': 123,
'ValidUntil': datetime(2015, 1, 1),
'InstanceInterruptionBehavior': 'hibernate'|'stop'|'terminate'
}
},