hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.12k forks source link

aws_emr_cluster Spot price natively set to 'Max (on-demand)' feature for more cost efficient and more secure Workload #7155

Open dthauvin opened 5 years ago

dthauvin commented 5 years ago

Community Note

Description

The api EMR natively provided the way to set the maximum Spot price at On-demand price whenMarket parameter is set to SPOT and BidPrice at NULL.

This is really important when you pay attention to the price.

This feature allows us to assign the current price of the SPOT course and allows us to keep our emr workload up to the On-demand price. This more cost efficient and more secure for your Workload .

This information is not in the aws APIreference but you can find it on boto3 documentation.

bidPrice EMR API-reference

boto3 EMR bidPrice and Market parameters

BidPrice (string) --
The maximum Spot price you are willing to pay for EC2 instances.

An optional, nullable field that applies if the MarketType for the instance group is specified as SPOT.
Specify the maximum spot price in USD.
If the value is NULL and SPOT is specified, the maximum Spot price is set equal to the On-Demand price.

Affected Resource(s)

Potential Terraform Configuration

We can add a new parameter like Market which can take two value : ON_DEMAND | SPOT bid_price parameter if set to blank send a null value in the API payload .


  instance_group {
    instance_role  = "CORE"
    instance_type  = "c4.large"
    instance_count = "1"
    ebs_config {
      size                 = "40"
      type                 = "gp2"
      volumes_per_instance = 1
    }
    market              = "SPOT | ON-DEMAND"
    bid_price          = ""
}

Actual CODE

terraform-provider-aws/aws/resource_aws_emr_cluster.go

unc expandBidPrice(config *emr.InstanceGroupConfig, configAttributes map[string]interface{}) {
    if bidPrice, ok := configAttributes["bid_price"]; ok {
        if bidPrice != "" {
            config.BidPrice = aws.String(bidPrice.(string))
            config.Market = aws.String("SPOT")
        } else {
            config.Market = aws.String("ON_DEMAND")
        }
    }
}

Screen

capture d ecran 2019-01-16 a 11 51 18

info wrong in Docs

Info about biprice on Master Instance group is wrong Actually i can bid on Master Instance group

bid_price - (Optional) If set, the bid price for each EC2 instance in the instance group, expressed in USD.
By setting this attribute, the instance group is being declared as a Spot Instance, and will implicitly create a Spot request. 
Leave this blank to use On-Demand Instances.
bid_price can not be set for the MASTER instance group, since that group must always be On-Demand
zeako commented 5 years ago

Any update regarding this issue? seems like a minor change

realvictorprm commented 3 years ago

same question here

karannnn-exe commented 1 year ago

Any updated on this?

karannnn-exe commented 1 year ago

bid_price = "OnDemandPrice" I used this parameter to use_on_demand_as_max_price. But it failed Error: ValidationException: The bid price is invalid. Revise the configuration and resubmit. │ status code: 400, request id: c07e612b-fd9d-4324-a9ab-522276c0cee8