User guide

Table Of Contents
{
DeviceIndex = 0,
SubnetId = subnetID,
Groups = groups,
AssociatePublicIpAddress = true
};
List<InstanceNetworkInterfaceSpecification> enis = new List<InstanceNetwork
InterfaceSpecification>() {eni};
DeviceIndex
The index of the device on the instance for the network interface attachment.
SubnetId
The ID of the subnet to launch the instance into.
GroupIds
One or more security groups. For more information, see Create a Security Group (p. 37).
AssociatePublicIpAddress
Indicates whether to auto-assign a public IP address to an instance in a VPC.
2. Create and initialize a RunInstancesRequest object. Make sure that the AMI, key pair, and security
group that you specify exist in the region that you specified when you created the client object.
string amiID = "ami-e189c8d1";
string keyPairName = "my-sample-key";
var launchRequest = new RunInstancesRequest()
{
ImageId = amiID,
InstanceType = "t1.micro",
MinCount = 1,
MaxCount = 1,
KeyName = keyPairName,
NetworkInterfaces = enis
};
ImageId
The ID of the AMI. For a list of public AMIs provided by Amazon, see Amazon Machine Images.
InstanceType
An instance type that is compatible with the specified AMI. For more information, see Instance
Types in the Amazon Elastic Compute Cloud User Guide for Microsoft Windows.
MinCount
The minimum number of EC2 instances to launch. If this is more instances than Amazon EC2
can launch in the target Availability Zone, Amazon EC2 launches no instances.
MaxCount
The maximum number of EC2 instances to launch. If this is more instances than Amazon EC2
can launch in the target Availability Zone, Amazon EC2 launches the largest possible number
of instances above MinCount.You can launch between 1 and the maximum number of instances
you're allowed for the instance type. For more information, see How many instances can I run
in Amazon EC2 in the Amazon EC2 General FAQ.
KeyName
The name of the EC2 key pair. If you launch an instance without specifying a key pair, you can't
connect to it. For more information, see Create a Key Pair (p. 40).
NetworkInterfaces
One or more network interfaces.
Version v2.0.0
44
AWS SDK for .NET Developer Guide
Launch an EC2 Instance