User guide

Table Of Contents
Checking the State of Your Instance (p. 46)
Connecting to Your Running Instance (p. 46)
Launching an EC2 Instance
You launch an instance in either EC2-Classic or EC2-VPC. For more information about EC2-Classic and
EC2-VPC, see Supported Platforms in the Amazon Elastic Compute Cloud User Guide for Microsoft
Windows.
To launch an EC2 instance in EC2-Classic
1. 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";
List<string> groups = new List<string>() { mySG.GroupId };
var launchRequest = new RunInstancesRequest()
{
ImageId = amiID,
InstanceType = "t1.micro",
MinCount = 1,
MaxCount = 1,
KeyName = keyPairName,
SecurityGroupIds = groups
};
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).
SecurityGroupIds
One or more security groups. For more information, see Create a Security Group (p. 37).
2. (Optional) To launch the instance with an IAM role (p. 47), specify an IAM instance profile in the
RunInstancesRequest.
Note that an IAM user can't launch an instance with an IAM role without the permissions granted by
the following policy.
Version v2.0.0
42
AWS SDK for .NET Developer Guide
Launch an EC2 Instance