Determine the current "on demand" price and use as spot price (maximum) #391
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
With this PR it is possible to run spot instances without specifying the spot price. If the spot price is set to "on-demand-price", the instance are requested for a price up to the current on demand price. The AWS cloud ensures that not more than the on demand price is billed.
You can still specify the price manually if needed, e. g. "0.06" for $0.06/hour.
The default behavior for
docker_machine_spot_price_bid
is changed from $0.06/hour to the current on demand price for the instance type chosen. So if there are no strong reasons to specify a lower price, simply stay with the default and remove the assignment of this variable.A new value is introduced for
runner_instance_spot_price
. Select "on-demand-price" to create a spot instance and you will not pay more than the current on demand price for that instance type. You do not have to look up this value and/or change it later in case the price changes.Closes #222
Migrations required
In case you selected the spot price manually, replace the manual value with "on-demand-price". But if you had a good reason for selecting a lower value, you can simply stay with it.
Verification
Manual verification done in our development environment by deploying the module using different combinations for the spot price. I checked the spot price requests in the AWS Console to show the price entered in the Terraform script. In case "on-demand-price" was selected, AWS automatically selected the current on demand price for the instance type chosen.
I also verified that the instances were able to process jobs.
Documentation
We use pre-commit to update the Terraform inputs and outputs in the documentation via terraform-docs. Ensure you have installed those components.