Example usage for com.amazonaws.services.ec2.model AssociateRouteTableResult getAssociationId

List of usage examples for com.amazonaws.services.ec2.model AssociateRouteTableResult getAssociationId

Introduction

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

Prototype


public String getAssociationId() 

Source Link

Document

The route table association ID.

Usage

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

License:Apache License

/**
 *
 * @param routeTableId//from  w w  w . j  a v a  2 s .  c  o  m
 * @param subnetId
 * @param ec2Client
 * @return
 */
public String associateRouteTableWithSubnet(String routeTableId, String subnetId, AmazonEC2 ec2Client) {
    String assId = null;
    try {
        AssociateRouteTableRequest request = new AssociateRouteTableRequest().withRouteTableId(routeTableId)
                .withSubnetId(subnetId);
        AssociateRouteTableResult result = ec2Client.associateRouteTable(request);

        if (result != null) {
            assId = result.getAssociationId();
        }
    } catch (AmazonServiceException e) {
        log.error("Failed to associate Route Table with Subnet", e);
        if (!"InvalidRouteTableID.NotFound".equalsIgnoreCase(e.getErrorCode())) {
            throw e;
        }
    }

    return assId;
}