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

旧巷老猫 提交于 2020-01-05 05:03:11

问题


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

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

    bid_price = "0.30"

I would require the bid_price = "max on-demand". Not sure how to pass this parameter in terraform.


回答1:


I figured out a way. However, included couple of scripts to fetch the price details.

Something like this:

AWS price cmd:

 InstanceType=$1
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 $2}' | sed -r 's/.{8}$//'| sed 's/$/"/'

Terraform code:

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]
  }
}



回答2:


I found an on-going issue from GitHub.

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

It is not yet applied and it seems that the feature what you want doesn't exist yet.



来源:https://stackoverflow.com/questions/57167443/emr-creation-task-and-core-nodes-not-able-to-specify-as-max-on-demand-for-spot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!