EMR 创建任务和核心节点无法指定为 "Max on demand" 以进行现货定价

EMR creation task and core nodes not able to specify as "Max on demand" for spot pricing

core_instance_group {
    instance_type  = "c4.large"
    instance_count = 1

    ebs_config {
      size                 = "40"
      type                 = "gp2"
      volumes_per_instance = 1
    }

    bid_price = "0.30"

我需要 bid_price = "max on-demand"。不确定如何在 terraform 中传递此参数。

我从 GitHub 中发现了一个持续存在的问题。

https://github.com/terraform-providers/terraform-provider-aws/issues/7155

尚未应用,似乎还没有您想要的功能

我想出了一个办法。但是,包括几个脚本来获取价格详细信息。

像这样:

A​​WS 价格指令:

 InstanceType=
aws pricing get-products --filters Type=TERM_MATCH,Field=instanceType,Value=${InstanceType} Type=TERM_MATCH,Field=capacityStatus,Value=Used Type=TERM_MATCH,Field=operatingSystem,Value=Linux Type=TERM_MATCH,Field=location,Value="US East (N. Virginia)" Type=TERM_MATCH,Field=preInstalledSw,Value=NA Type=TERM_MATCH,Field=tenancy,Value=Shared --format-version aws_v1 --region us-east-1 --service-code AmazonEC2 | jq '.PriceList[]' | sed 's/\//g' | sed -e 's/^.//' -e 's/.$//' | jq '.terms.OnDemand' | jq '(.. | .pricePerUnit?)' | grep "USD" | awk '{print }' | sed -r 's/.{8}$//'| sed 's/$/"/'

地形代码:

resource "null_resource" "price_details" {
  provisioner "local-exec" {
    command = "/root/gv/price.sh ${var.core-type} 2>stderr >stdout; echo $? >exitstatus"
  }
}

data "external" "stdout" {
  depends_on = [null_resource.price_details]
  program    = ["sh", "/opt/terraform-test/read.sh", "/opt/terraform-test/stdout"]
}

resource "null_resource" "contents" {
  depends_on = [null_resource.price_details]

  triggers = {
    stdout     = data.external.stdout.result["content"]
  }
  lifecycle {
    ignore_changes = [triggers]
  }
}