Feature request: Allow aws_instance resource to create and manage spot instances #1243
Labels
enhancement
Requests to existing resources that expand the functionality or scope.
service/ec2
Issues and PRs that pertain to the ec2 service.
stale
Old or inactive issues managed by automation, if no further action taken these will get closed.
I haven't taken a particularly long look at the code to see how much impact this would have but it would be nice if the
aws_instance
resource could be used to manage spot instances instead of having to explicitly use theaws_spot_instance_request
resource.This would simplify being able to switch between spot and on demand requests without duplicating code. As it is I have a module that creates EC2 instances and then a bunch of other dependent resources (Route53 records, Cloudwatch alarms etc) and I'm going to have to duplicate the
aws_instance
resource plus all the resources dependent on it to use theaws_spot_instance_request
and also make them conditional on whether a spot price has been set.So as a minimal example I'll have something like:
But with a lot more duplicated configuration between the
aws_instance
andaws_spot_instance_request
and also anything else that needs the instance id, private IP address or other computed attributes.Instead I'd love to just do:
Where the
aws_instance
resource takes an optionalspot_price
(plus other spot related config) and if it gets an empty string or isn't provided then it creates an on demand instance instead.Would people be open to complicating the code in the
aws_instance
module to allow for this simpler interface? I'd guess it probably adds a fair bit more complexity to things in the code but I'm not sure if there's an specific steer away from that if it enables users (the vast majority of people) to more easily do something like this.The text was updated successfully, but these errors were encountered: