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. Spot instances are instances that Amazon EC2 launches when the bid price that you specify exceeds the current Spot price. Amazon EC2 periodically sets the Spot price based on available Spot Instance capacity and current Spot instance requests. For more information, see Spot Instance Requests in the Amazon Elastic Compute Cloud User Guide.

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 bids.

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 bids 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 bid is expired, or the bid falls below current market), 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.

The required duration for the Spot instances (also known as Spot blocks), in minutes. This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360).

The duration period starts as soon as your Spot instance receives its instance ID. At the end of the duration period, Amazon EC2 marks the Spot instance for termination and provides a Spot instance termination notice, which gives the instance a two-minute warning before it terminates.

Note that you can't specify an Availability Zone group or a launch group if you specify a duration.

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 Elastic Compute Cloud User Guide.

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.

Indicates whether a Spot instance stops or terminates when it is interrupted.

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 hourly price (bid) for any Spot instance launched to fulfill the request.

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 ValidFrom.

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.

Default: The request is effective indefinitely.

Public Property ValidUntil System.DateTime

Gets and sets the property ValidUntil.

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

Default: The request is effective indefinitely.

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. If your account supports EC2-Classic, Amazon EC2 launches the instances in EC2-Classic in the specified Availability Zone.

To create a one-time Spot Instance request


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 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 Standard:
Supported in: 1.3

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

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms