github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/aws/r/spot_fleet_request.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_spot_fleet_request" 4 sidebar_current: "docs-aws-resource-spot-fleet-request" 5 description: |- 6 Provides a Spot Fleet Request resource. 7 --- 8 9 # aws\_spot\_fleet\_request 10 11 Provides an EC2 Spot Fleet Request resource. This allows a fleet of Spot 12 instances to be requested on the Spot market. 13 14 ## Example Usage 15 16 ```hcl 17 # Request a Spot fleet 18 resource "aws_spot_fleet_request" "cheap_compute" { 19 iam_fleet_role = "arn:aws:iam::12345678:role/spot-fleet" 20 spot_price = "0.03" 21 allocation_strategy = "diversified" 22 target_capacity = 6 23 valid_until = "2019-11-04T20:44:20Z" 24 25 launch_specification { 26 instance_type = "m4.10xlarge" 27 ami = "ami-1234" 28 spot_price = "2.793" 29 } 30 31 launch_specification { 32 instance_type = "m4.4xlarge" 33 ami = "ami-5678" 34 key_name = "my-key" 35 spot_price = "1.117" 36 availability_zone = "us-west-1a" 37 subnet_id = "subnet-1234" 38 weighted_capacity = 35 39 40 root_block_device { 41 volume_size = "300" 42 volume_type = "gp2" 43 } 44 } 45 } 46 ``` 47 48 ~> **NOTE:** Terraform does not support the functionality where multiple `subnet_id` or `availability_zone` parameters can be specified in the same 49 launch configuration block. If you want to specify multiple values, then separate launch configuration blocks should be used: 50 51 ```hcl 52 resource "aws_spot_fleet_request" "foo" { 53 iam_fleet_role = "arn:aws:iam::12345678:role/spot-fleet" 54 spot_price = "0.005" 55 target_capacity = 2 56 valid_until = "2019-11-04T20:44:20Z" 57 58 launch_specification { 59 instance_type = "m1.small" 60 ami = "ami-d06a90b0" 61 key_name = "my-key" 62 availability_zone = "us-west-2a" 63 } 64 65 launch_specification { 66 instance_type = "m3.large" 67 ami = "ami-d06a90b0" 68 key_name = "my-key" 69 availability_zone = "us-west-2a" 70 } 71 72 depends_on = ["aws_iam_policy_attachment.test-attach"] 73 } 74 ``` 75 76 ## Argument Reference 77 78 Most of these arguments directly correspond to the 79 [official API](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_SpotFleetRequestConfigData.html). 80 81 * `iam_fleet_role` - (Required) Grants the Spot fleet permission to terminate 82 Spot instances on your behalf when you cancel its Spot fleet request using 83 CancelSpotFleetRequests or when the Spot fleet request expires, if you set 84 terminateInstancesWithExpiration. 85 * `replace_unhealthy_instances` - (Optional) Indicates whether Spot fleet should replace unhealthy instances. Default `false`. 86 * `launch_specification` - Used to define the launch configuration of the 87 spot-fleet request. Can be specified multiple times to define different bids 88 across different markets and instance types. 89 90 **Note:** This takes in similar but not 91 identical inputs as [`aws_instance`](instance.html). There are limitations on 92 what you can specify (tags, for example, are not supported). See the 93 list of officially supported inputs in the 94 [reference documentation](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_SpotFleetLaunchSpecification.html). Any normal [`aws_instance`](instance.html) parameter that corresponds to those inputs may be used. 95 96 * `spot_price` - (Required) The bid price per unit hour. 97 * `target_capacity` - The number of units to request. You can choose to set the 98 target capacity in terms of instances or a performance characteristic that is 99 important to your application workload, such as vCPUs, memory, or I/O. 100 * `allocation_strategy` - Indicates how to allocate the target capacity across 101 the Spot pools specified by the Spot fleet request. The default is 102 lowestPrice. 103 * `excess_capacity_termination_policy` - Indicates whether running Spot 104 instances should be terminated if the target capacity of the Spot fleet 105 request is decreased below the current size of the Spot fleet. 106 * `terminate_instances_with_expiration` - Indicates whether running Spot 107 instances should be terminated when the Spot fleet request expires. 108 * `valid_until` - The end date and time of the request, in UTC ISO8601 format 109 (for example, YYYY-MM-DDTHH:MM:SSZ). At this point, no new Spot instance 110 requests are placed or enabled to fulfill the request. Defaults to 24 hours. 111 112 ## Attributes Reference 113 114 The following attributes are exported: 115 116 * `id` - The Spot fleet request ID 117 * `spot_request_state` - The state of the Spot fleet request.