本规范不适合我启动和停止aws的实例

时间:2015-01-09 13:01:15

标签: .net windows amazon-web-services amazon-ec2

AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client();            

//启动您的实例

ec2.StartInstances(new StartInstancesRequest().WithInstanceId("i-00000000"));         

//停止

ec2.StopInstances(new StopInstancesRequest().WithInstanceId("i-00000000"));

1 个答案:

答案 0 :(得分:1)

这是使用.net和启动实例的一个很好的(官方)指南:http://docs.aws.amazon.com/AWSSdkDocsNET/latest/DeveloperGuide/run-instance.html

您无法自己命名实例,并且需要指定更多信息。这是在该页面上找到的一个例子。

string amiID = "ami-e189c8d1";
string keyPairName = "my-sample-key";

var groups = new List<string>() { mySG.GroupId };
var launchRequest = new RunInstancesRequest()
{
    ImageId = amiID,
    InstanceType = "t1.micro",
    MinCount = 1,
    MaxCount = 1,
    KeyName = keyPairName,
    SecurityGroupIds = groups
};