【问题标题】:AWS boto3 - how to run a spot instance?AWS boto3 - 如何运行现货实例?
【发布时间】:2020-05-24 03:24:43
【问题描述】:

我目前这样做是为了从 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

我可以在此处添加一个属性来将其作为现场实例运行吗?

【问题讨论】:

    标签: amazon-web-services amazon-ec2 aws-lambda boto3


    【解决方案1】:

    create_instances() 命令中有一个参数用于 Spot 实例:

        InstanceMarketOptions={
            'MarketType': 'spot',
            'SpotOptions': {
                'MaxPrice': 'string',
                'SpotInstanceType': 'one-time'|'persistent',
                'BlockDurationMinutes': 123,
                'ValidUntil': datetime(2015, 1, 1),
                'InstanceInterruptionBehavior': 'hibernate'|'stop'|'terminate'
            }
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-09
      • 2017-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-21
      • 2015-10-10
      • 2020-01-22
      相关资源
      最近更新 更多