你可以试试这个。。
AmazonEC2Client amazonEc2client = GetAmazonClient(ConfigurationManager.AppSettings["AwsRegionEndPint"]);
var launchRequest = new RunInstancesRequest()
{
ImageId = YOUR IMAGE ID,
InstanceType = YOUR INSTANCE TYPE,
MinCount = 1,
MaxCount = 1,
KeyName = your keyPairName,
SecurityGroupIds =your groups,
SubnetId = your subnet Id,
};
RunInstancesResponse runInstancesResponse = amazonEc2client.RunInstances(launchRequest);
//代码用于分配标签名称
var InstanceId = runInstancesResponse.Reservation.Instances[0].InstanceId;
var trequest = new CreateTagsRequest();
trequest.Resources=new List<string>(){InstanceId};
List<Tag> tags=new List<Tag>();
Tag tag=new Tag("Name","TestCodeFinal");
tags.Add(tag);
trequest.Tags = tags;
amazonEc2client.CreateTags(trequest);
Reservation reservation = runInstancesResponse.Reservation;