use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class DeleteSecurityGroup method deleteEC2SecGroup.
// snippet-start:[ec2.java2.delete_security_group.main]
public static void deleteEC2SecGroup(Ec2Client ec2, String groupId) {
try {
DeleteSecurityGroupRequest request = DeleteSecurityGroupRequest.builder().groupId(groupId).build();
ec2.deleteSecurityGroup(request);
System.out.printf("Successfully deleted Security Group with id %s", groupId);
} catch (Ec2Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class DeleteSecurityGroup method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <groupId> \n\n" + "Where:\n" + " groupId - a security group id that you can obtain from the AWS Console (for example, sg-xxxxxx1c0b65785c3).";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String groupId = args[0];
Region region = Region.US_WEST_2;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
deleteEC2SecGroup(ec2, groupId);
ec2.close();
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class DescribeAddresses method main.
public static void main(String[] args) {
Region region = Region.US_WEST_2;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
describeEC2Address(ec2);
ec2.close();
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class ReleaseAddress method releaseEC2Address.
// snippet-start:[ec2.java2.release_instance.main]
public static void releaseEC2Address(Ec2Client ec2, String allocId) {
try {
ReleaseAddressRequest request = ReleaseAddressRequest.builder().allocationId(allocId).build();
ReleaseAddressResponse response = ec2.releaseAddress(request);
System.out.printf("Successfully released elastic IP address %s", allocId);
} catch (Ec2Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class DeleteKeyPair method deleteKeys.
// snippet-start:[ec2.java2.delete_key_pair.main]
public static void deleteKeys(Ec2Client ec2, String keyPair) {
try {
DeleteKeyPairRequest request = DeleteKeyPairRequest.builder().keyName(keyPair).build();
DeleteKeyPairResponse response = ec2.deleteKeyPair(request);
System.out.printf("Successfully deleted key pair named %s", keyPair);
} catch (Ec2Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations