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

Calls the Amazon Elastic Compute Cloud (EC2) RequestSpotInstances API operation.

Syntax

Request-EC2SpotInstance
-SpotPrice <String>
-LaunchSpecification_AddressingType <String>
-LaunchSpecification_AllSecurityGroup <GroupIdentifier[]>
-IamInstanceProfile_Arn <String>
-Placement_AvailabilityZone <String>
-AvailabilityZoneGroup <String>
-LaunchSpecification_BlockDeviceMapping <BlockDeviceMapping[]>
-BlockDurationMinute <Int32>
-LaunchSpecification_EbsOptimized <Boolean>
-Placement_GroupName <String>
-LaunchSpecification_ImageId <String>
-InstanceCount <Int32>
-InstanceInterruptionBehavior <InstanceInterruptionBehavior>
-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[]>
-LaunchSpecification_SubnetId <String>
-TagSpecification <TagSpecification[]>
-Placement_Tenancy <Tenancy>
-Type <SpotInstanceType>
-LaunchSpecification_UserData <String>
-UtcValidFrom <DateTime>
-UtcValidUntil <DateTime>
-ClientToken <String>
-ValidFrom <DateTime>
-ValidUntil <DateTime>
-Select <String>
-PassThru <SwitchParameter>
-Force <SwitchParameter>
-ClientConfig <AmazonEC2Config>

Description

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.

Parameters

-AvailabilityZoneGroup <String>
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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-BlockDurationMinute <Int32>
Deprecated.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesBlockDurationMinutes
-ClientConfig <AmazonEC2Config>
Amazon.PowerShell.Cmdlets.EC2.AmazonEC2ClientCmdlet.ClientConfig
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-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 EC2 User Guide for Linux Instances.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
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?True (ByPropertyName)
-IamInstanceProfile_Arn <String>
The Amazon Resource Name (ARN) of the instance profile.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesLaunchSpecification_IamInstanceProfile_Arn
-IamInstanceProfile_Name <String>
The name of the instance profile.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesLaunchSpecification_IamInstanceProfile_Name
-InstanceCount <Int32>
The maximum number of Spot Instances to launch.Default: 1
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-InstanceInterruptionBehavior <InstanceInterruptionBehavior>
The behavior when a Spot Instance is interrupted. The default is terminate.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-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?True (ByPropertyName)
-LaunchSpecification_AddressingType <String>
Deprecated.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_AllSecurityGroup <GroupIdentifier[]>
The IDs of the security groups.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesLaunchSpecification_AllSecurityGroups
-LaunchSpecification_BlockDeviceMapping <BlockDeviceMapping[]>
The block device mapping entries.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesLaunchSpecification_BlockDeviceMappings
-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?True (ByPropertyName)
-LaunchSpecification_ImageId <String>
The ID of the AMI.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_InstanceType <InstanceType>
The instance type. Only one instance type can be specified.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_KernelId <String>
The ID of the kernel.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_KeyName <String>
The name of the key pair.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_MonitoringEnabled <Boolean>
The service has not provided documentation for this parameter; please refer to the service's API reference documentation for the latest available information.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_NetworkInterface <InstanceNetworkInterfaceSpecification[]>
The 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?True (ByPropertyName)
AliasesLaunchSpecification_NetworkInterfaces
-LaunchSpecification_RamdiskId <String>
The ID of the RAM disk.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_SecurityGroup <String[]>
One or more security group names.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesLaunchSpecification_SecurityGroups
-LaunchSpecification_SubnetId <String>
The ID of the subnet in which to launch the instance.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LaunchSpecification_UserData <String>
The base64-encoded user data that instances use when starting up. User data is limited to 16 KB.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PassThru <SwitchParameter>
Changes the cmdlet behavior to return the value passed to the SpotPrice parameter. The -PassThru parameter is deprecated, use -Select '^SpotPrice' instead. This parameter will be removed in a future version.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-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?True (ByPropertyName)
AliasesLaunchSpecification_Placement_AvailabilityZone
-Placement_GroupName <String>
The name of the placement group.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesLaunchSpecification_Placement_GroupName
-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?True (ByPropertyName)
AliasesLaunchSpecification_Placement_Tenancy
-Select <String>
Use the -Select parameter to control the cmdlet output. The default value is 'SpotInstanceRequests'. Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.EC2.Model.RequestSpotInstancesResponse). Specifying the name of a property of type Amazon.EC2.Model.RequestSpotInstancesResponse will result in that property being returned. Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-SpotPrice <String>
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.
Required?False
Position?1
Accept pipeline input?True (ByValue, ByPropertyName)
-TagSpecification <TagSpecification[]>
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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTagSpecifications
The Spot Instance request type.Default: one-time
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-UtcValidFrom <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.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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-UtcValidUntil <DateTime>
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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ValidFrom <DateTime>
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.This parameter is deprecated.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ValidUntil <DateTime>
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.
This parameter is deprecated.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)

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?True (ByPropertyName)
AliasesAK
-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?True (ByValue, ByPropertyName)
-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?True (ByPropertyName)
-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?True (ByValue, ByPropertyName)
-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.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?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-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?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-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?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

This cmdlet returns a collection of Amazon.EC2.Model.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

$n = New-Object Amazon.EC2.Model.InstanceNetworkInterfaceSpecification
$n.DeviceIndex = 0
$n.SubnetId = "subnet-12345678"
$n.Groups.Add("sg-12345678")
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