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

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

Introduction

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

Prototype

DeleteVpcResult deleteVpc(DeleteVpcRequest deleteVpcRequest);

Source Link

Document

Deletes the specified VPC.

Usage

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

License:Apache License

/**
 *
 * @param vpcId/* w  ww .  j  a  v  a  2  s.  c  o  m*/
 * @param ec2Client
 */
public void deleteVpc(String vpcId, AmazonEC2 ec2Client) {
    try {
        log.info("Deleting Vpc (" + vpcId + ")");
        DeleteVpcRequest request = new DeleteVpcRequest().withVpcId(vpcId);
        ec2Client.deleteVpc(request);
    } catch (AmazonServiceException e) {
        log.error("Failed to delete Vpc", e);
        if (!"InvalidVpcID.NotFound".equalsIgnoreCase(e.getErrorCode())) {
            throw e;
        }
    }
}