问题
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