Search in sources :

Example 1 with ReleaseAddressResponse

use of software.amazon.awssdk.services.ec2.model.ReleaseAddressResponse 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);
    }
}
Also used : ReleaseAddressResponse(software.amazon.awssdk.services.ec2.model.ReleaseAddressResponse) Ec2Exception(software.amazon.awssdk.services.ec2.model.Ec2Exception) ReleaseAddressRequest(software.amazon.awssdk.services.ec2.model.ReleaseAddressRequest)

Aggregations

Ec2Exception (software.amazon.awssdk.services.ec2.model.Ec2Exception)1 ReleaseAddressRequest (software.amazon.awssdk.services.ec2.model.ReleaseAddressRequest)1 ReleaseAddressResponse (software.amazon.awssdk.services.ec2.model.ReleaseAddressResponse)1