Amazon AWS SDK Guide de l'utilisateur Page 83 : Connecting to Your Running Instance
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
List<Instance> runningInstances = statusResponse.DescribeInstancesResult.Re
servation[0].Instance;
foreach (Instance instance in runningInstances)
{
Console.WriteLine("Instance status: " + instance.InstanceState.Name);
}
Connecting to Your Running Instance
After an instance is running, you can remotely connect to it using an RDP client on your computer. Before
connecting to your instance, you must ensure that the instance's RDP port is open to traffic. To connect,
you need the instance ID and the private key for instance's key pair. For more information, see
Connecting
to Your Windows Instance Using RDP
in the
Amazon EC2 User Guide for Microsoft Windows Instances
.
When you have finished with your EC2 instance, see
Terminate an EC2 Instance (p. 79)
.
Terminate an EC2 Instance Using the SDK for .NET
When you no longer need one or more of your EC2 instances, you can terminate them.
To terminate an EC2 instance
Create and initialize a
TerminateInstancesRequest
object. Set the
InstanceIds
property to a list of one or
more instance IDs. In this example,
instanceIds
is the list that you saved when you launched the
instances.
Pass the request object to the client object's
TerminateInstances
method.
var deleteRequest = new TerminateInstancesRequest()
{
InstanceIds = instanceIds
};
var deleteResponse = ec2Client.TerminateInstances(deleteRequest);
foreach (InstanceStateChange item in deleteResponse.TerminatingInstances)
{
Console.WriteLine();
Console.WriteLine("Terminated instance: " + item.InstanceId);
Console.WriteLine("Instance state: " + item.CurrentState.Name);
}
To list the terminated instances
You can use the response object as follows to list the terminated instances.
List<InstanceStateChange> terminatedInstances = termResponse.TerminateInstances
Result.TerminatingInstance;
foreach(InstanceStateChange item in terminatedInstances)
{
Console.WriteLine("Terminated Instance: " + item.InstanceId);
}
Version v2.0.0
79
AWS SDK for .NET Developer Guide
Tutorial: Creating Amazon EC2 Instances
Fichier PDF · ·
Questions sur Amazon AWS SDK
Pas encore de questions sur ce manuel. Posez la première.
Produits connexes et manuels pour Logiciel Amazon AWS SDK
- Logiciel Amazon Redshift Manuel d'utilisateur
(24 pages) - Logiciel Amazon Redshift Manuel d'utilisateur
(11 pages) - Logiciel Amazon AWS SDK Guide de l'utilisateur
(73 pages)