Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Spot Instance request example launch specifications

Focus mode
Spot Instance request example launch specifications - Amazon Elastic Compute Cloud

The following examples show launch configurations that you can use with the request-spot-instances command to create a Spot Instance request. For more information, see Manage your Spot Instances.

Important

We strongly discourage using the request-spot-instances command to request a Spot Instance because it is a legacy API with no planned investment. For more information, see Which is the best Spot request method to use?

Example 1: Launch Spot Instances

The following example does not include an Availability Zone or subnet. Amazon EC2 selects an Availability Zone for you. Amazon EC2 launches the instances in the default subnet of the selected Availability Zone.

{ "ImageId": "ami-0abcdef1234567890", "KeyName": "my-key-pair", "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ], "InstanceType": "m5.medium", "IamInstanceProfile": { "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role" } }

Example 2: Launch Spot Instances in the specified Availability Zone

The following example includes an Availability Zone. Amazon EC2 launches the instances in the default subnet of the specified Availability Zone.

{ "ImageId": "ami-0abcdef1234567890", "KeyName": "my-key-pair", "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ], "InstanceType": "m5.medium", "Placement": { "AvailabilityZone": "us-west-2a" }, "IamInstanceProfile": { "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role" } }

Example 3: Launch Spot Instances in the specified subnet

The following example includes a subnet. Amazon EC2 launches the instances in the specified subnet. If the VPC is a nondefault VPC, the instance does not receive a public IPv4 address by default.

{ "ImageId": "ami-0abcdef1234567890", "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ], "InstanceType": "m5.medium", "SubnetId": "subnet-1a2b3c4d", "IamInstanceProfile": { "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role" } }

To assign a public IPv4 address to an instance in a nondefault VPC, specify the AssociatePublicIpAddress field as shown in the following example. When you specify a network interface, you must include the subnet ID and security group ID using the network interface, rather than using the SubnetId and SecurityGroupIds fields shown in the previous code block.

{ "ImageId": "ami-0abcdef1234567890", "KeyName": "my-key-pair", "InstanceType": "m5.medium", "NetworkInterfaces": [ { "DeviceIndex": 0, "SubnetId": "subnet-1a2b3c4d5e6f7g8h9", "Groups": [ "sg-1a2b3c4d5e6f7g8h9" ], "AssociatePublicIpAddress": true } ], "IamInstanceProfile": { "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role" } }

Example 4: Launch a Dedicated Spot Instance

The following example requests Spot Instance with a tenancy of dedicated. A Dedicated Spot Instance must be launched in a VPC.

{ "ImageId": "ami-0abcdef1234567890", "KeyName": "my-key-pair", "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ], "InstanceType": "c5.8xlarge", "SubnetId": "subnet-1a2b3c4d5e6f7g8h9", "Placement": { "Tenancy": "dedicated" } }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.