github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/website/source/docs/providers/aws/r/spot_instance_request.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_spot_instance_request" 4 sidebar_current: "docs-aws-resource-spot-instance-request" 5 description: |- 6 Provides a Spot Instance Request resource. 7 --- 8 9 # aws\_spot\_instance\_request 10 11 Provides an EC2 Spot Instance Request resource. This allows instances to be 12 requested on the spot market. 13 14 Terraform always creates Spot Instance Requests with a `persistent` type, which 15 means that for the duration of their lifetime, AWS will launch an instance 16 with the configured details if and when the spot market will accept the 17 requested price. 18 19 On destruction, Terraform will make an attempt to terminate the associated Spot 20 Instance if there is one present. 21 22 ~> **NOTE:** Because their behavior depends on the live status of the spot 23 market, Spot Instance Requests have a unique lifecycle that makes them behave 24 differently than other Terraform resources. Most importantly: there is __no 25 guarantee__ that a Spot Instance exists to fulfill the request at any given 26 point in time. See the [AWS Spot Instance 27 documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html) 28 for more information. 29 30 31 ## Example Usage 32 33 ``` 34 # Request a spot instance at $0.03 35 resource "aws_spot_instance_request" "cheap_worker" { 36 ami = "ami-1234" 37 spot_price = "0.03" 38 instance_type = "c4.xlarge" 39 tags { 40 Name = "CheapWorker" 41 } 42 } 43 ``` 44 45 ## Argument Reference 46 47 Spot Instance Requests support all the same arguments as 48 [`aws_instance`](instance.html), with the addition of: 49 50 * `spot_price` - (Required) The price to request on the spot market. 51 * `wait_for_fulfillment` - (Optional; Default: false) If set, Terraform will 52 wait for the Spot Request to be fulfilled, and will throw an error if the 53 timeout of 10m is reached. 54 * `spot_type` - (Optional; Default: "persistent") If set to "one-time", after 55 the instance is terminated, the spot request will be closed. Also, Terraform 56 can't manage one-time spot requests, just launch them. 57 * `block_duration_minutes` - (Optional) The required duration for the Spot instances, in minutes. This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360). 58 The duration period starts as soon as your Spot instance receives its instance ID. At the end of the duration period, Amazon EC2 marks the Spot instance for termination and provides a Spot instance termination notice, which gives the instance a two-minute warning before it terminates. 59 Note that you can't specify an Availability Zone group or a launch group if you specify a duration. 60 61 ## Attributes Reference 62 63 The following attributes are exported: 64 65 * `id` - The Spot Instance Request ID. 66 67 These attributes are exported, but they are expected to change over time and so 68 should only be used for informational purposes, not for resource dependencies: 69 70 * `spot_bid_status` - The current [bid 71 status](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-bid-status.html) 72 of the Spot Instance Request. 73 * `spot_request_state` The current [request 74 state](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#creating-spot-request-status) 75 of the Spot Instance Request. 76 * `spot_instance_id` - The Instance ID (if any) that is currently fulfilling 77 the Spot Instance request. 78 * `public_dns` - The public DNS name assigned to the instance. For EC2-VPC, this 79 is only available if you've enabled DNS hostnames for your VPC 80 * `public_ip` - The public IP address assigned to the instance, if applicable. 81 * `private_dns` - The private DNS name assigned to the instance. Can only be 82 used inside the Amazon EC2, and only available if you've enabled DNS hostnames 83 for your VPC 84 * `private_ip` - The private IP address assigned to the instance