AWS SDK Version 2 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.

.NET Framework 3.5
 
Container for the parameters to the RunInstances operation. Launches the specified number of instances using an AMI for which you have permissions.

When you launch an instance, it enters the pending state. After the instance is ready for you, it enters the running state. To check the state of your instance, call DescribeInstances.

If you don't specify a security group when launching an instance, Amazon EC2 uses the default security group. For more information, see Security Groups in the Amazon Elastic Compute Cloud User Guide.

[EC2-VPC only accounts] If you don't specify a subnet in the request, we choose a default subnet from your default VPC for you.

[EC2-Classic accounts] If you're launching into EC2-Classic and you don't specify an Availability Zone, we choose one for you.

Linux instances have access to the public key of the key pair at boot. You can use this key to provide secure access to the instance. Amazon EC2 public images use this feature to provide secure access without passwords. For more information, see Key Pairs in the Amazon Elastic Compute Cloud User Guide.

You can provide optional user data when launching an instance. For more information, see Instance Metadata in the Amazon Elastic Compute Cloud User Guide.

If any of the AMIs have a product code attached for which the user has not subscribed, RunInstances fails.

T2 instance types can only be launched into a VPC. If you do not have a default VPC, or if you do not specify a subnet ID in the request, RunInstances fails.

For more information about troubleshooting, see What To Do If An Instance Immediately Terminates, and Troubleshooting Connecting to Your Instance in the Amazon Elastic Compute Cloud User Guide.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.EC2.AmazonEC2Request
      Amazon.EC2.Model.RunInstancesRequest

Namespace: Amazon.EC2.Model
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public class RunInstancesRequest : AmazonEC2Request
         IRequestEvents

The RunInstancesRequest type exposes the following members

Constructors

NameDescription
Public Method RunInstancesRequest() Empty constructor used to set properties independently even when a simple constructor is available
Public Method RunInstancesRequest(string, int, int) Instantiates RunInstancesRequest with the parameterized properties

Properties

NameTypeDescription
Public Property AdditionalInfo System.String Gets and sets the property AdditionalInfo.

Reserved.

Public Property BlockDeviceMappings System.Collections.Generic.List<Amazon.EC2.Model.BlockDeviceMapping> Gets and sets the property BlockDeviceMappings.

The block device mapping.

Public Property ClientToken System.String Gets and sets the property ClientToken.

Unique, case-sensitive identifier you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency.

Constraints: Maximum 64 ASCII characters

Public Property DisableApiTermination System.Boolean Gets and sets the property DisableApiTermination.

If you set this parameter to true, you can't terminate the instance using the Amazon EC2 console, CLI, or API; otherwise, you can. If you set this parameter to true and then later want to be able to terminate the instance, you must first change the value of the disableApiTermination attribute to false using ModifyInstanceAttribute. Alternatively, if you set InstanceInitiatedShutdownBehavior to terminate, you can terminate the instance by running the shutdown command from the instance.

Default: false

Public Property EbsOptimized System.Boolean Gets and sets the property EbsOptimized.

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

Public Property IamInstanceProfile Amazon.EC2.Model.IamInstanceProfileSpecification Gets and sets the property IamInstanceProfile.

The IAM instance profile.

Public Property ImageId System.String Gets and sets the property ImageId.

The ID of the AMI, which you can get by calling DescribeImages.

Public Property InstanceInitiatedShutdownBehavior Amazon.EC2.ShutdownBehavior Gets and sets the property InstanceInitiatedShutdownBehavior.

Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).

Default: stop

Public Property InstanceType Amazon.EC2.InstanceType Gets and sets the property InstanceType.

The instance type. For more information, see Instance Types in the Amazon Elastic Compute Cloud User Guide.

Default: m1.small

Public Property KernelId System.String Gets and sets the property KernelId.

The ID of the kernel.

We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see PV-GRUB in the Amazon Elastic Compute Cloud User Guide.

Public Property KeyName System.String Gets and sets the property KeyName.

The name of the key pair. You can create a key pair using CreateKeyPair or ImportKeyPair.

If you do not specify a key pair, you can't connect to the instance unless you choose an AMI that is configured to allow users another way to log in.

Public Property MaxCount System.Int32 Gets and sets the property MaxCount.

The maximum number of instances to launch. If you specify more instances than Amazon EC2 can launch in the target Availability Zone, Amazon EC2 launches the largest possible number of instances above MinCount.

Constraints: Between 1 and the maximum number you're allowed for the specified instance type. For more information about the default limits, and how to request an increase, see How many instances can I run in Amazon EC2 in the Amazon EC2 General FAQ.

Public Property MinCount System.Int32 Gets and sets the property MinCount.

The minimum number of instances to launch. If you specify a minimum that is more instances than Amazon EC2 can launch in the target Availability Zone, Amazon EC2 launches no instances.

Constraints: Between 1 and the maximum number you're allowed for the specified instance type. For more information about the default limits, and how to request an increase, see How many instances can I run in Amazon EC2 in the Amazon EC2 General FAQ.

Public Property Monitoring System.Boolean Gets and sets the property Monitoring.

The monitoring for the instance.

Public Property NetworkInterfaces System.Collections.Generic.List<Amazon.EC2.Model.InstanceNetworkInterfaceSpecification> Gets and sets the property NetworkInterfaces.

One or more network interfaces.

Public Property Placement Amazon.EC2.Model.Placement Gets and sets the property Placement.

The placement for the instance.

Public Property PrivateIpAddress System.String Gets and sets the property PrivateIpAddress.

[EC2-VPC] The primary IP address. You must specify a value from the IP address range of the subnet.

Only one private IP address can be designated as primary. Therefore, you can't specify this parameter if PrivateIpAddresses.n.Primary is set to true and PrivateIpAddresses.n.PrivateIpAddress is set to an IP address.

Default: We select an IP address from the IP address range of the subnet.

Public Property RamdiskId System.String Gets and sets the property RamdiskId.

The ID of the RAM disk.

We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see PV-GRUB in the Amazon Elastic Compute Cloud User Guide.

Public Property SecurityGroupIds System.Collections.Generic.List<System.String> Gets and sets the property SecurityGroupIds.

One or more security group IDs. You can create a security group using CreateSecurityGroup.

Default: Amazon EC2 uses the default security group.

Public Property SecurityGroups System.Collections.Generic.List<System.String> Gets and sets the property SecurityGroups.

[EC2-Classic, default VPC] One or more security group names. For a nondefault VPC, you must use security group IDs instead.

Default: Amazon EC2 uses the default security group.

Public Property SubnetId System.String Gets and sets the property SubnetId.

[EC2-VPC] The ID of the subnet to launch the instance into.

Public Property UserData System.String Gets and sets the property UserData.

The Base64-encoded MIME user data for the instances.

Version Information

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

.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8

.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8