Example usage for com.amazonaws.services.ec2 AmazonEC2 deleteSubnet

List of usage examples for com.amazonaws.services.ec2 AmazonEC2 deleteSubnet

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2 deleteSubnet.

Prototype

DeleteSubnetResult deleteSubnet(DeleteSubnetRequest deleteSubnetRequest);

Source Link

Document

Deletes the specified subnet.

Usage

From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java

License:Apache License

/**
 *
 * @param subnetId// w  ww  . j ava2  s . c o m
 * @param ec2Client
 */
public void deleteSubnet(String subnetId, AmazonEC2 ec2Client) {
    try {
        log.info("Deleting Subnet (" + subnetId + ")");
        DeleteSubnetRequest request = new DeleteSubnetRequest().withSubnetId(subnetId);
        ec2Client.deleteSubnet(request);
    } catch (AmazonServiceException e) {
        log.error("Failed to delete Subnet", e);
        if (!"InvalidSubnetId.NotFound".equals(e.getErrorCode())) {
            throw e;
        }
    }

}