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