From a3111b41e53fe1b2775cab00a19eb05c2b01adef Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Wed, 23 Sep 2015 15:30:44 -0300 Subject: [PATCH 1/2] Allow non-persistent spot requests --- .../aws/resource_aws_spot_instance_request.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_spot_instance_request.go b/builtin/providers/aws/resource_aws_spot_instance_request.go index 56de8992c..89384246c 100644 --- a/builtin/providers/aws/resource_aws_spot_instance_request.go +++ b/builtin/providers/aws/resource_aws_spot_instance_request.go @@ -36,6 +36,11 @@ func resourceAwsSpotInstanceRequest() *schema.Resource { Required: true, ForceNew: true, } + s["spot_type"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "persistent", + } s["wait_for_fulfillment"] = &schema.Schema{ Type: schema.TypeBool, Optional: true, @@ -69,10 +74,7 @@ func resourceAwsSpotInstanceRequestCreate(d *schema.ResourceData, meta interface spotOpts := &ec2.RequestSpotInstancesInput{ SpotPrice: aws.String(d.Get("spot_price").(string)), - - // We always set the type to "persistent", since the imperative-like - // behavior of "one-time" does not map well to TF's declarative domain. - Type: aws.String("persistent"), + Type: aws.String(d.Get("spot_type").(string)), // Though the AWS API supports creating spot instance requests for multiple // instances, for TF purposes we fix this to one instance per request. From 362024056ff0a9add8e87621dedc07b2ec31e677 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Wed, 23 Sep 2015 15:35:47 -0300 Subject: [PATCH 2/2] docs --- .../docs/providers/aws/r/spot_instance_request.html.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/source/docs/providers/aws/r/spot_instance_request.html.markdown b/website/source/docs/providers/aws/r/spot_instance_request.html.markdown index abb1f4705..5ca6daf9f 100644 --- a/website/source/docs/providers/aws/r/spot_instance_request.html.markdown +++ b/website/source/docs/providers/aws/r/spot_instance_request.html.markdown @@ -51,6 +51,9 @@ Spot Instance Requests support all the same arguments as * `wait_for_fulfillment` - (Optional; Default: false) If set, Terraform will wait for the Spot Request to be fulfilled, and will throw an error if the timeout of 10m is reached. +* `spot_type` - (Optional; Default: "persistent") If set to "one-time", after + the instance is terminated, the spot request will be closed. Also, Terraform + can't manage one-time spot requests, just launch them. ## Attributes Reference