如何在 CloudFormation 脚本中指定 Spot 实例定价

How to designate spot instance pricing in a CloudFormation script

我正在 CloudFormation 脚本中创建一个 EMR 集群,并且我能够成功 运行 它完成并构建堆栈,但现在我想知道如何在还有 CF 模板。

这是我正在使用的集群创建:

"Resources": {
    "MyCluster": {
        "Type": "AWS::EMR::Cluster",
        "Properties": {
            "Applications": [
                { "Name" : "Hadoop" },
                { "Name" : "SPARK" },
                { "Name" : "Ganglia" }
            ],
            "BootstrapActions" : [...],
            "Instances": {
                "AdditionalMasterSecurityGroups" : [{ "Fn::GetAtt" : ["rAllowJupyter","GroupId"] }],
                "Ec2KeyName" : { "Ref" : "EC2KeyName" },
                "Ec2SubnetId" : { "Ref" : "Subnet" },
                "MasterInstanceGroup": {
                    "InstanceCount": 1,
                    "InstanceType": { "Ref" : "InstanceType" }
                },
                "CoreInstanceGroup": {
                    "InstanceCount": { "Ref" : "CoreNodeCount" },
                    "InstanceType": { "Ref" : "InstanceType" }
                }
            },
            "Configurations": [...],
            "Name": "MyCluster",
            "JobFlowRole": "EMR_EC2_DefaultRole",
            "ServiceRole": "EMR_DefaultRole",
            "ReleaseLabel": "emr-4.6.0",
            "LogUri": "s3://path/to/logs/",
            "Tags": [
                { "Key": "Name", "Value": "aqa-spark"},
                { "Key": "Owner",   "Value": { "Ref" : "OwnerTag" }},
                { "Key": "Purpose", "Value": { "Ref" : "PurposeTag" }}
            ]
        }
    }
},

是否有参数可用于为我的 CloudFormation 脚本指定 EMR 集群中的现场实例?

您可以通过向配置添加 MarketBidPrice 参数,使 MasterInstanceGroup(或任何其他)使用 spot 实例。

例如,要以 0.10 美元的价格购买 r3.large 个现货实例:

"MasterInstanceGroup": {
  "InstanceCount": 1,
  "InstanceType": "r3.large",
  "Market": "SPOT",
  "BidPrice": "0.10"
}

来源:Amazon EMR Cluster JobFlowInstancesConfig InstanceGroupConfig 文档