AWS Tools for Windows PowerShell
Command 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.

Synopsis

Invokes the RequestSpotInstances operation against Amazon Elastic Compute Cloud.

Syntax

Request-EC2SpotInstance
-LaunchSpecification_AddressingType <String>
-LaunchSpecification_AllSecurityGroup <GroupIdentifier[]>
-IamInstanceProfile_Arn <String>
-Placement_AvailabilityZone <String>
-AvailabilityZoneGroup <String>
-LaunchSpecification_BlockDeviceMapping <BlockDeviceMapping[]>
-BlockDurationMinute <Int32>
-ClientToken <String>
-LaunchSpecification_EbsOptimized <Boolean>
-Placement_GroupName <String>
-LaunchSpecification_ImageId <String>
-InstanceCount <Int32>
-LaunchSpecification_InstanceType <InstanceType>
-LaunchSpecification_KernelId <String>
-LaunchSpecification_KeyName <String>
-LaunchGroup <String>
-LaunchSpecification_MonitoringEnabled <Boolean>
-IamInstanceProfile_Name <String>
-LaunchSpecification_NetworkInterface <InstanceNetworkInterfaceSpecification[]>
-LaunchSpecification_RamdiskId <String>
-LaunchSpecification_SecurityGroup <String[]>
-SpotPrice <String>
-LaunchSpecification_SubnetId <String>
-Placement_Tenancy <Tenancy>
-Type <SpotInstanceType>
-LaunchSpecification_UserData <String>
-ValidFrom <DateTime>
-ValidUntil <DateTime>
-Force <SwitchParameter>

Description

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.

Parameters

-AvailabilityZoneGroup <String>
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.
Required?False
Position?Named
Accept pipeline input?False
-BlockDurationMinute <Int32>
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.
Required?False
Position?Named
Accept pipeline input?False
-ClientToken <String>
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.
Required?False
Position?Named
Accept pipeline input?False
-Force <SwitchParameter>
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?False
-IamInstanceProfile_Arn <String>
The Amazon Resource Name (ARN) of the instance profile.
Required?False
Position?Named
Accept pipeline input?False
-IamInstanceProfile_Name <String>
The name of the instance profile.
Required?False
Position?Named
Accept pipeline input?False
-InstanceCount <Int32>
The maximum number of Spot instances to launch.Default: 1
Required?False
Position?Named
Accept pipeline input?False
-LaunchGroup <String>
The instance launch group. Launch groups are Spot instances that launch together and terminate together.Default: Instances are launched and terminated individually
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_AddressingType <String>
Deprecated.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_AllSecurityGroup <GroupIdentifier[]>
One or more security groups. When requesting instances in a VPC, you must specify the IDs of the security groups. When requesting instances in EC2-Classic, you can specify the names or the IDs of the security groups.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_BlockDeviceMapping <BlockDeviceMapping[]>
One or more block device mapping entries.Although you can specify encrypted EBS volumes in this block device mapping for your Spot Instances, these volumes are not encrypted.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_EbsOptimized <Boolean>
Indicates whether the instance is optimized for EBS I/O. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal EBS I/O performance. This optimization isn't available with all instance types. Additional usage charges apply when using an EBS Optimized instance.Default: false
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_ImageId <String>
The ID of the AMI.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_InstanceType <InstanceType>
The instance type.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_KernelId <String>
The ID of the kernel.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_KeyName <String>
The name of the key pair.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_MonitoringEnabled <Boolean>
Documentation for this parameter is not currently available; please refer to the service API documentation.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_NetworkInterface <InstanceNetworkInterfaceSpecification[]>
One or more network interfaces. If you specify a network interface, you must specify subnet IDs and security group IDs using the network interface.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_RamdiskId <String>
The ID of the RAM disk.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_SecurityGroup <String[]>
One or more security group names.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_SubnetId <String>
The ID of the subnet in which to launch the instance.
Required?False
Position?Named
Accept pipeline input?False
-LaunchSpecification_UserData <String>
The user data to make available to the instances. If you are using an AWS SDK or command line tool, Base64-encoding is performed for you, and you can load the text from a file. Otherwise, you must provide Base64-encoded text.
Required?False
Position?Named
Accept pipeline input?False
-Placement_AvailabilityZone <String>
The Availability Zone.[Spot fleet only] To specify multiple Availability Zones, separate them using commas; for example, "us-west-2a, us-west-2b".
Required?False
Position?Named
Accept pipeline input?False
-Placement_GroupName <String>
The name of the placement group (for cluster instances).
Required?False
Position?Named
Accept pipeline input?False
-Placement_Tenancy <Tenancy>
The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for Spot instances.
Required?False
Position?Named
Accept pipeline input?False
-SpotPrice <String>
The maximum hourly price (bid) for any Spot instance launched to fulfill the request.
Required?False
Position?Named
Accept pipeline input?False
The Spot instance request type.Default: one-time
Required?False
Position?Named
Accept pipeline input?False
-ValidFrom <DateTime>
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.
Required?False
Position?Named
Accept pipeline input?False
-ValidUntil <DateTime>
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.
Required?False
Position?Named
Accept pipeline input?False

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required? False
Position? Named
Accept pipeline input? False
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required? False
Position? Named
Accept pipeline input? False
-ProfileLocation <String>

Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)

If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials. Note that the encrypted credential file is not supported on all platforms. It will be skipped when searching for profiles on Windows Nano Server, Mac, and Linux platforms.

If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.

As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.

Required? False
Position? Named
Accept pipeline input? False
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required? False
Position? Named
Accept pipeline input? False
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required? False
Position? Named
Accept pipeline input? False
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required? False
Position? Named
Accept pipeline input? False
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required? False
Position? Named
Accept pipeline input? False
-Region <String>
The system name of the AWS region in which the operation should be invoked. For example, us-east-1, eu-west-1 etc.
Required? False
Position? Named
Accept pipeline input? False
-EndpointUrl <String>

The endpoint to make the call against.

Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.

Required? False
Position? Named
Accept pipeline input? False

Inputs

This cmdlet does not accept pipeline input.

Outputs

This cmdlet returns a collection of SpotInstanceRequest objects. The service call response (type Amazon.EC2.Model.RequestSpotInstancesResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack.

Examples

Example 1

PS C:\> $n = New-Object Amazon.EC2.Model.InstanceNetworkInterfaceSpecification
PS C:\> $n.DeviceIndex = 0
PS C:\> $n.SubnetId = "subnet-12345678"
PS C:\> $n.Groups.Add("sg-12345678")
PS C:\> Request-EC2SpotInstance -InstanceCount 1 -SpotPrice 0.050 -Type one-time `
-IamInstanceProfile_Arn arn:aws:iam::123456789012:instance-profile/my-iam-role `
-LaunchSpecification_ImageId ami-12345678 `
-LaunchSpecification_InstanceType m3.medium `
-LaunchSpecification_NetworkInterface $n

ActualBlockHourlyPrice :
AvailabilityZoneGroup :
BlockDurationMinutes : 0
CreateTime : 12/26/2015 7:44:10 AM
Fault :
InstanceId :
LaunchedAvailabilityZone :
LaunchGroup :
LaunchSpecification : Amazon.EC2.Model.LaunchSpecification
ProductDescription : Linux/UNIX
SpotInstanceRequestId : sir-12345678
SpotPrice : 0.050000
State : open
Status : Amazon.EC2.Model.SpotInstanceStatus
Tags : {}
Type : one-time
This example requests a one-time Spot instance in the specified subnet. Note that the security group must be created for the VPC that contains the specified subnet, and it must be specified by ID using the network interface. When you specify a network interface, you must include the subnet ID using the network interface.

Supported Version

AWS Tools for PowerShell: 2.x.y.z