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