use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class DescribeAccount method main.
public static void main(String[] args) {
// Create an Ec2Client object
Region region = Region.US_WEST_2;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
describeEC2Account(ec2);
System.out.print("Done");
ec2.close();
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class DescribeInstanceTags method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <resourceId> \n\n" + "Where:\n" + " resourceId - the instance ID value that you can obtain from the AWS Console (for example, i-xxxxxx0913e05f482). \n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String resourceId = args[0];
Region region = Region.US_EAST_1;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
describeEC2Tags(ec2, resourceId);
ec2.close();
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class DescribeKeyPairs method main.
public static void main(String[] args) {
Region region = Region.US_WEST_2;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
describeEC2Keys(ec2);
ec2.close();
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class MonitorInstance method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <instanceId> <monitor>\n\n" + "Where:\n" + " instanceId - an instance id value that you can obtain from the AWS Console. \n\n" + " monitor - a monitoring status (true|false)";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String instanceId = args[0];
boolean monitor = Boolean.valueOf(args[1]);
Region region = Region.US_WEST_2;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
if (monitor) {
monitorInstance(ec2, instanceId);
} else {
unmonitorInstance(ec2, instanceId);
}
ec2.close();
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class MonitorInstance method monitorInstance.
// snippet-start:[ec2.java2.monitor_instance.main]
public static void monitorInstance(Ec2Client ec2, String instanceId) {
MonitorInstancesRequest request = MonitorInstancesRequest.builder().instanceIds(instanceId).build();
ec2.monitorInstances(request);
System.out.printf("Successfully enabled monitoring for instance %s", instanceId);
}
Aggregations