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

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

Introduction

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

Prototype

CreateRouteTableResult createRouteTable(CreateRouteTableRequest createRouteTableRequest);

Source Link

Document

Creates a route table for the specified VPC.

Usage

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

License:Apache License

/**
 *
 * @param vpcId/*from   ww w. j  av  a 2s .co m*/
 * @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;
}