BAEL-1572: Use instance ID of newly created instance for the rest of the examples

This commit is contained in:
orrym 2018-03-05 20:48:37 +02:00
parent 92bf897874
commit f4a7946634
1 changed files with 2 additions and 4 deletions

View File

@ -39,8 +39,6 @@ public class EC2Application {
public static void main(String[] args) {
String yourInstanceId = "<you-instance>";
// 0) - Set up the client
AmazonEC2 ec2Client = AmazonEC2ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
@ -91,7 +89,7 @@ public class EC2Application {
.withKeyName("baeldung-key-pair") // optional - if not present, can't connect to instance
.withSecurityGroups("BaeldungSecurityGroup");
ec2Client.runInstances(runInstancesRequest);
String yourInstanceId = ec2Client.runInstances(runInstancesRequest).getReservation().getInstances().get(0).getInstanceId();
// 6) Monitor Instances
MonitorInstancesRequest monitorInstancesRequest = new MonitorInstancesRequest()