Description
Community Note
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Description
EC2 allows choosing multiple allocation strategies for spot requests. It would be great to be able to specify the Allocation strategy for packer builds on Spot.
Use Case(s)
In our use case (building AMIs in CI/CD) we are seeing frequent evictions of spot instances mid-build, or even before launching the build instances. It could help to choose a strategy like capacity-optimized
or price-capacity-optimized
, in order to see less frequent evictions and failures due to lack of capacity.
Potential configuration
An option that exposes spot_allocation_strategy
on the AWS builder would do the trick. That option could still default to lowest-price
for backwards behavioral compatibility. But price-capacity-optimized
is the recommended value.
Potential References
It looks like the AWS SDK exposes this configuration point as an Enum (sorry, this file is to big to permalink to):
https://github.com/aws/aws-sdk-go/blob/main/service/ec2/api.go
I think it would only be a matter of adding that option to the spot fleet request here?
packer-plugin-amazon/builder/common/step_run_spot_instance.go
Lines 368 to 384 in e8a4526
From there, a configuration option would need to be exposed from input and threaded to the fleet request.
Apologies if this is too vague, as i'm not very well versed in Go.