FEATURES OPEN SOURCE ABOUT DOCS LOGIN REGISTER

aws_spot_instance_request

Provides an EC2 Spot Instance Request resource. This allows instances to be requested on the spot market.

Terraform always creates Spot Instance Requests with a persistent type, which means that for the duration of their lifetime, AWS will launch an instance with the configured details if and when the spot market will accept the requested price.

On destruction, Terraform will make an attempt to terminate the associated Spot Instance if there is one present.

~> NOTE: Because their behavior depends on the live status of the spot market, Spot Instance Requests have a unique lifecycle that makes them behave differently than other Terraform resources. Most importantly: there is no guarantee that a Spot Instance exists to fulfill the request at any given point in time. See the AWS Spot Instance documentation for more information.

Example Usage

# Request a spot instance at $0.03
resource "aws_spot_instance_request" "cheap_worker" {
    ami = "ami-1234"
    spot_price = "0.03"
    instance_type = "c4.xlarge"
    tags {
        Name = "CheapWorker"
    }
}

Argument Reference

Spot Instance Requests support all the same arguments as aws_instance, with the addition of:

Attributes Reference

The following attributes are exported:

These attributes are exported, but they are expected to change over time and so should only be used for informational purposes, not for resource dependencies:


See the source of this document at Terraform.io