AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Container for the parameters to the RequestSpotInstances operation. Creates a Spot Instance request.

For more information, see Spot Instance requests in the Amazon EC2 User Guide for Linux Instances.

We strongly discourage using the RequestSpotInstances API because it is a legacy API with no planned investment. For options for requesting Spot Instances, see Which is the best Spot request method to use? in the Amazon EC2 User Guide for Linux Instances.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.EC2.AmazonEC2Request
      Amazon.EC2.Model.RequestSpotInstancesRequest

Namespace: Amazon.EC2.Model
Assembly: AWSSDK.EC2.dll
Version: 3.x.y.z

Syntax

C#
public class RequestSpotInstancesRequest : AmazonEC2Request
         IAmazonWebServiceRequest

The RequestSpotInstancesRequest type exposes the following members

Constructors

NameDescription
Public Method RequestSpotInstancesRequest()

Empty constructor used to set properties independently even when a simple constructor is available

Public Method RequestSpotInstancesRequest(string)

Instantiates RequestSpotInstancesRequest with the parameterized properties

Properties

NameTypeDescription
Public Property AvailabilityZoneGroup System.String

Gets and sets the property AvailabilityZoneGroup.

The user-specified name for a logical grouping of requests.

When you specify an Availability Zone group in a Spot Instance request, all Spot Instances in the request are launched in the same Availability Zone. Instance proximity is maintained with this parameter, but the choice of Availability Zone is not. The group applies only to requests for Spot Instances of the same instance type. Any additional Spot Instance requests that are specified with the same Availability Zone group name are launched in that same Availability Zone, as long as at least one instance from the group is still active.

If there is no active instance running in the Availability Zone group that you specify for a new Spot Instance request (all instances are terminated, the request is expired, or the maximum price you specified falls below current Spot price), then Amazon EC2 launches the instance in any Availability Zone where the constraint can be met. Consequently, the subsequent set of Spot Instances could be placed in a different zone from the original request, even if you specified the same Availability Zone group.

Default: Instances are launched in any available Availability Zone.

Public Property BlockDurationMinutes System.Int32

Gets and sets the property BlockDurationMinutes.

Deprecated.

Public Property ClientToken System.String

Gets and sets the property ClientToken.

Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to Ensure Idempotency in the Amazon EC2 User Guide for Linux Instances.

Public Property InstanceCount System.Int32

Gets and sets the property InstanceCount.

The maximum number of Spot Instances to launch.

Default: 1

Public Property InstanceInterruptionBehavior Amazon.EC2.InstanceInterruptionBehavior

Gets and sets the property InstanceInterruptionBehavior.

The behavior when a Spot Instance is interrupted. The default is terminate.

Public Property LaunchGroup System.String

Gets and sets the property LaunchGroup.

The instance launch group. Launch groups are Spot Instances that launch together and terminate together.

Default: Instances are launched and terminated individually

Public Property LaunchSpecification Amazon.EC2.Model.LaunchSpecification

Gets and sets the property LaunchSpecification.

The launch specification.

Public Property SpotPrice System.String

Gets and sets the property SpotPrice.

The maximum price per unit hour that you are willing to pay for a Spot Instance. We do not recommend using this parameter because it can lead to increased interruptions. If you do not specify this parameter, you will pay the current Spot price.

If you specify a maximum price, your instances will be interrupted more frequently than if you do not specify this parameter.

Public Property TagSpecifications System.Collections.Generic.List<Amazon.EC2.Model.TagSpecification>

Gets and sets the property TagSpecifications.

The key-value pair for tagging the Spot Instance request on creation. The value for ResourceType must be spot-instances-request, otherwise the Spot Instance request fails. To tag the Spot Instance request after it has been created, see CreateTags.

Public Property Type Amazon.EC2.SpotInstanceType

Gets and sets the property Type.

The Spot Instance request type.

Default: one-time

Public Property ValidFrom System.DateTime

Gets and sets the property ValidFromUtc.

This property is deprecated. Setting this property results in non-UTC DateTimes not being marshalled correctly. Use ValidFromUtc instead. Setting either ValidFrom or ValidFromUtc results in both ValidFrom and ValidFromUtc being assigned, the latest assignment to either one of the two property is reflected in the value of both. ValidFrom is provided for backwards compatibility only and assigning a non-Utc DateTime to it results in the wrong timestamp being passed to the service.

The start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled.

The specified start date and time cannot be equal to the current date and time. You must specify a start date and time that occurs after the current date and time.

Public Property ValidFromUtc System.DateTime

Gets and sets the property ValidFromUtc.

The start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled.

The specified start date and time cannot be equal to the current date and time. You must specify a start date and time that occurs after the current date and time.

Public Property ValidUntil System.DateTime

Gets and sets the property ValidUntilUtc.

This property is deprecated. Setting this property results in non-UTC DateTimes not being marshalled correctly. Use ValidUntilUtc instead. Setting either ValidUntil or ValidUntilUtc results in both ValidUntil and ValidUntilUtc being assigned, the latest assignment to either one of the two property is reflected in the value of both. ValidUntil is provided for backwards compatibility only and assigning a non-Utc DateTime to it results in the wrong timestamp being passed to the service.

The end date of the request, in UTC format (YYYY-MM-DDTHH:MM:SSZ).

  • For a persistent request, the request remains active until the ValidUntil date and time is reached. Otherwise, the request remains active until you cancel it.

  • For a one-time request, the request remains active until all instances launch, the request is canceled, or the ValidUntil date and time is reached. By default, the request is valid for 7 days from the date the request was created.

Public Property ValidUntilUtc System.DateTime

Gets and sets the property ValidUntilUtc.

The end date of the request, in UTC format (YYYY-MM-DDTHH:MM:SSZ).

  • For a persistent request, the request remains active until the ValidUntil date and time is reached. Otherwise, the request remains active until you cancel it.

  • For a one-time request, the request remains active until all instances launch, the request is canceled, or the ValidUntil date and time is reached. By default, the request is valid for 7 days from the date the request was created.

Examples

This example creates a one-time Spot Instance request for five instances in the specified Availability Zone. If your account supports EC2-VPC only, Amazon EC2 launches the instances in the default subnet of the specified Availability Zone.

To create a one-time Spot Instance request


var client = new AmazonEC2Client();
var response = client.RequestSpotInstances(new RequestSpotInstancesRequest 
{
    InstanceCount = 5,
    LaunchSpecification = new RequestSpotLaunchSpecification {
        IamInstanceProfile = new IamInstanceProfileSpecification { Arn = "arn:aws:iam::123456789012:instance-profile/my-iam-role" },
        ImageId = "ami-1a2b3c4d",
        InstanceType = "m3.medium",
        KeyName = "my-key-pair",
        Placement = new SpotPlacement { AvailabilityZone = "us-west-2a" },
                    
    },
    SpotPrice = "0.03",
    Type = "one-time"
});


            

This example command creates a one-time Spot Instance request for five instances in the specified subnet. Amazon EC2 launches the instances in the specified subnet. If the VPC is a nondefault VPC, the instances do not receive a public IP address by default.

To create a one-time Spot Instance request


var client = new AmazonEC2Client();
var response = client.RequestSpotInstances(new RequestSpotInstancesRequest 
{
    InstanceCount = 5,
    LaunchSpecification = new RequestSpotLaunchSpecification {
        IamInstanceProfile = new IamInstanceProfileSpecification { Arn = "arn:aws:iam::123456789012:instance-profile/my-iam-role" },
        ImageId = "ami-1a2b3c4d",
        InstanceType = "m3.medium",
        SubnetId = "subnet-1a2b3c4d"
    },
    SpotPrice = "0.050",
    Type = "one-time"
});


            

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5, 4.0, 3.5