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.

Contains the output of RequestSpotFleet.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceResponse
    Amazon.EC2.Model.RequestSpotFleetResponse

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

Syntax

C#
public class RequestSpotFleetResponse : AmazonWebServiceResponse

The RequestSpotFleetResponse type exposes the following members

Constructors

NameDescription
Public Method RequestSpotFleetResponse()

Properties

NameTypeDescription
Public Property ContentLength System.Int64 Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property HttpStatusCode System.Net.HttpStatusCode Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property ResponseMetadata Amazon.Runtime.ResponseMetadata Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property SpotFleetRequestId System.String

Gets and sets the property SpotFleetRequestId.

The ID of the Spot fleet request.

Examples

This example creates a Spot fleet request with two launch specifications that differ only by subnet. The Spot fleet launches the instances in the specified subnet with the lowest price. If the instances are launched in a default VPC, they receive a public IP address by default. If the instances are launched in a nondefault VPC, they do not receive a public IP address by default. Note that you can't specify different subnets from the same Availability Zone in a Spot fleet request.

To request a Spot fleet in the subnet with the lowest price


var response = client.RequestSpotFleet(new RequestSpotFleetRequest 
{
    SpotFleetRequestConfig = new SpotFleetRequestConfigData {
        IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
        LaunchSpecifications = new List {
            new SpotFleetLaunchSpecification {
                IamInstanceProfile = new IamInstanceProfileSpecification { Arn = "arn:aws:iam::123456789012:instance-profile/my-iam-role" },
                ImageId = "ami-1a2b3c4d",
                InstanceType = "m3.medium",
                KeyName = "my-key-pair",
                SecurityGroups = new List {
                    new GroupIdentifier { GroupId = "sg-1a2b3c4d" }
                },
                SubnetId = "subnet-1a2b3c4d, subnet-3c4d5e6f"
            }
        },
        SpotPrice = "0.04",
        TargetCapacity = 2
    }
});

string spotFleetRequestId = response.SpotFleetRequestId;

            

This example creates a Spot fleet request with two launch specifications that differ only by Availability Zone. The Spot fleet launches the instances in the specified Availability Zone with the lowest price. If your account supports EC2-VPC only, Amazon EC2 launches the Spot instances in the default subnet of the Availability Zone. If your account supports EC2-Classic, Amazon EC2 launches the instances in EC2-Classic in the Availability Zone.

To request a Spot fleet in the Availability Zone with the lowest price


var response = client.RequestSpotFleet(new RequestSpotFleetRequest 
{
    SpotFleetRequestConfig = new SpotFleetRequestConfigData {
        IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
        LaunchSpecifications = new List {
            new SpotFleetLaunchSpecification {
                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, us-west-2b" },
                SecurityGroups = new List {
                    new GroupIdentifier { GroupId = "sg-1a2b3c4d" }
                }
            }
        },
        SpotPrice = "0.04",
        TargetCapacity = 2
    }
});

string spotFleetRequestId = response.SpotFleetRequestId;

            

This example assigns public addresses to instances launched in a nondefault VPC. Note that when you specify a network interface, you must include the subnet ID and security group ID using the network interface.

To launch Spot instances in a subnet and assign them public IP addresses


var response = client.RequestSpotFleet(new RequestSpotFleetRequest 
{
    SpotFleetRequestConfig = new SpotFleetRequestConfigData {
        IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
        LaunchSpecifications = new List {
            new SpotFleetLaunchSpecification {
                IamInstanceProfile = new IamInstanceProfileSpecification { Arn = "arn:aws:iam::880185128111:instance-profile/my-iam-role" },
                ImageId = "ami-1a2b3c4d",
                InstanceType = "m3.medium",
                KeyName = "my-key-pair",
                NetworkInterfaces = new List {
                    new InstanceNetworkInterfaceSpecification {
                        AssociatePublicIpAddress = true,
                        DeviceIndex = 0,
                        Groups = new List {
                            "sg-1a2b3c4d"
                        },
                        SubnetId = "subnet-1a2b3c4d"
                    }
                }
            }
        },
        SpotPrice = "0.04",
        TargetCapacity = 2
    }
});

string spotFleetRequestId = response.SpotFleetRequestId;

            

This example creates a Spot fleet request that launches 30 instances using the diversified allocation strategy. The launch specifications differ by instance type. The Spot fleet distributes the instances across the launch specifications such that there are 10 instances of each type.

To request a Spot fleet using the diversified allocation strategy


var response = client.RequestSpotFleet(new RequestSpotFleetRequest 
{
    SpotFleetRequestConfig = new SpotFleetRequestConfigData {
        AllocationStrategy = "diversified",
        IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
        LaunchSpecifications = new List {
            new SpotFleetLaunchSpecification {
                ImageId = "ami-1a2b3c4d",
                InstanceType = "c4.2xlarge",
                SubnetId = "subnet-1a2b3c4d"
            },
            new SpotFleetLaunchSpecification {
                ImageId = "ami-1a2b3c4d",
                InstanceType = "m3.2xlarge",
                SubnetId = "subnet-1a2b3c4d"
            },
            new SpotFleetLaunchSpecification {
                ImageId = "ami-1a2b3c4d",
                InstanceType = "r3.2xlarge",
                SubnetId = "subnet-1a2b3c4d"
            }
        },
        SpotPrice = "0.70",
        TargetCapacity = 30
    }
});

string spotFleetRequestId = response.SpotFleetRequestId;

            

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