Example usage for com.amazonaws.services.ec2.model CreateRouteTableRequest CreateRouteTableRequest

List of usage examples for com.amazonaws.services.ec2.model CreateRouteTableRequest CreateRouteTableRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model CreateRouteTableRequest CreateRouteTableRequest.

Prototype

CreateRouteTableRequest

Source Link

Usage

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

License:Apache License

/**
 *
 * @param vpcId/* w  ww.ja v  a2 s  . c om*/
 * @param ec2Client
 * @return
 */
public String createRouteTable(String vpcId, AmazonEC2 ec2Client) {
    String routeTableId = null;
    try {
        CreateRouteTableRequest request = new CreateRouteTableRequest().withVpcId(vpcId);
        CreateRouteTableResult result = ec2Client.createRouteTable(request);
        if (result != null && result.getRouteTable() != null) {
            routeTableId = result.getRouteTable().getRouteTableId();
        }
    } catch (AmazonServiceException e) {
        log.error("Failed to create Route Table in Vpc " + vpcId, e);
        if (!"InvalidVpcID.NotFound".equalsIgnoreCase(e.getErrorCode())) {
            throw e;
        }
    }
    return routeTableId;
}